views:

55

answers:

2

Given a simple data set, I would like to be able to calculate a trending formula given it's a second order polynomial regression.

In fact, it would be great if one could even forecast X periods during calculation (similar to what Excel does).

I'm looking for a portable C/C++ package that's relatively easy to use, and allows it to spit out the "best-fit" (highest R^2 value) curve.

Any suggestions? Thanks!

+1  A: 

The GNU gsl C library can do multiparameter fits. Its interface is of course very C-like, but there are version for many platforms available, including for Windows.

See the quadratic fit example in the gsl documentation for how to implement this for your case.

honk
A: 

ROOT is c++ native and can run compiled or interpreted (using cint). The TGraph class and those derived from it support fitting with arbitrary function. Root is open source, runs on Mac, Windows, Linux, and OpenSolaris (and in principle on other unicies). It is, however, a pretty big tool to install just for the fitting support.

dmckee
I use ROOT as well, but like you said, installing it only for some simple Excelesque fits is a bit of an overkill (the I/O part its major strength anyway I guess). Also, mentioning it over here always makes the `R` people jump from their lairs.
honk