tags:

views:

2814

answers:

6

I am looking to perform a polynomial least squares regression and am looking for a C# library to do the calculations for me.

I pass in the data points and the degree of polynomal (2nd order, 3rd order, etc) and it returns either the C0, C1, C2 etc. constant values or the calculated values "predictions".

Note: I am using Least Squares to create some forecasting reports for disk usage, database size and table size.

+1  A: 

In the general case you want an "optimizer" or "mimimizer". See http://en.wikipedia.org/wiki/Optimization_(mathematics)#Solvers for some exmples. I see that the first link (http://en.wikipedia.org/wiki/IMSL_Numerical_Libraries) claims to have c# support.


Edit: For the limited use that you propose (linear or quadratic polynomials), you could just go to any copy of Numerical Recipies, grab a straight ahead implementation, and translate to your language. A general minimizer is overkill.

But note, also, that polynomials may be poor predictors.

dmckee
+1  A: 

We have used MathLibX in the past and it has worked quite well. I personally have used it to do a Least Square Fit "prediction" algorithm and found it very easy to use.

http://www.mathfunctions.com/index.htm

Price is $80, and it comes with 7 other functions.

Good Luck

AdamBT
Does this come with royalty free distribution
Robert Wilkinson
A: 

AdamBT, Does MathLibX provide royalty free distribution?

Robert Wilkinson
A: 

You may want to check out alglib. It is in C++ instead of C#, but you might be able to write a wrapper over it.

Adam Tegen
+6  A: 

Here is a link for C# code on to do exactly this: http://www.trentfguidry.net/post/2009/08/01/Linear-Regression-of-Polynomial-Coefficients.aspx

Good luck!

JP
A: 

You can check library form ALGLIB under GPL licence 2.0. They have source code for C#, C++,...

http://www.alglib.net/interpolation/leastsquares.php

Vlad Bezden