This project has moved and is read-only. For the latest updates, please go here.

Implementing Power, exponential and logarithmic function as best fit in C#

Sep 16, 2014 at 4:28 PM
Greetings,
Can somebody help me implementing following formula’s in C# for best fit?

Logarithmic Trendline
The Logarithmic trendline fits a line to ln(x), y–that is, y = a*ln(x) + b.

Exponential Trendline
The Exponential trendline fits the function y = a * e ^(b * x). This can also be computed using LinearRegression by fitting a line to x, ln(y). Taking the log of both sides of the function gives:
ln(y) = ln(a * e ^(b * x)) = ln(a) + bx

Power Trendline
The Power trendline fits the function y = a * x^b. This can be computed using LinearRegression by fitting a line to ln(x), ln(y). Taking the log of both sides of the equation gives:
ln(y) = ln(a * x^b) = ln(a) + b * ln(x)

All 3 functions can be implemented using lineair trendline.
For all 3 functions I need the: a and b factor and RSquared.
These 3 functions are common in Excell as trendline for best fit. Iám looking for a replacement for these Excel functions.

I already implemented:
Tuple<double, double> p = MathNet.Numerics.Fit.Line(xSloc, xPI)
For the normal lineair line: y = a + bx

But I don’t know how to implement the other 3 formules in MathNet.Numerics for best it.

The programming language is C#.

Thanks for a reply

Greetings
Peter Bellen
peter.bellen@12move.nl