Curve fitting: Power


(Eric Ouellet) #1

I’m looking to find a way to get curve fitting of type (Power) like in Excel Trending.

Actually, I found linear and polynomial as :

Tuple<double, double> line = Fit.Line(xdata, ydata);
double[] poly2 = Fit.Polynomial(xdata, ydata, 2);

Also cdnet answered how to do Exponential in Exponential Fit

But, I’m not sure how to find “Power” curve fitting? Anybody has an idea?


(Christoph Rüegg) #2

Assuming with power you’re referring to a target function along the lines of y : x -> a*x^b, then this is a simpler version of what I’ve described in Linearizing non-linear models by transformation.

This seems to be used often enough so I’ve started to add a new Fit.Power and Fit.Exponential locally for this case - not pushed yet since it first needs more testing, but I expect it to be part of v4.1.

Alternatively, by now we also support non-linear optimization which could also be used for use cases like this (FindMinimum module).


(Eric Ouellet) #3

Thanks a lots. I really appreciate your answer. I’m zero in math and will try to figure out how to use it exactly. I’m really happy to see that you plan to add that. I think it will be a welcome addition. Just as a reference, I think that all “Fit” functions that are available as trending in Excel should be implemented. (Note: In excel, you can choose point graphic from 2 columms with numbers, then right click on one point and choose trending).

I would also recommend to make specific results for those new “Fit” functions with intuitive property names. Like for “Fit” of “Power” ==> result coud be “CurveFitResultPower” class where there is a “pow” and “multiplicator” properties. (ie better names could be chosen, it is only as an example).

Also each “Fit” result could implement a standard interface where there will always be a “rSquare” property which could be used as input for other function which verify the validity of the fitting or anything a good math guy could want (don’t know - I’m bad in math).

Also an overloaded ToString which explain what you have would be really great!

But all of that are suggestions.


(Christoph Rüegg) #4

Fit.Power, Fit.Exponential and Fit.Logarithm have been released in v4.1.0.


(Eric Ouellet) #5

And I though I was an efficient programmer… Super Quick! WOW ! Thanks a lots!