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

linear regression with 3 points

Jan 18 at 2:13 PM
I need to get the formula of a 3 points curves
The extrem points are fixed (0,0) and (100,100) and the middle points move from (0,0)to (100,100).
The middle point is not linear and can be anywhere between the 2 extrems points.
As input for my formula I have a value that move from 0 to 100.
On the image you can see the middle point is at X=23 and Y=5.
Jan 19 at 9:44 PM
Hi sdecorme,

It's quite easy to do a three-point linear regression. Here is some code:
            BivariateSample sample = new BivariateSample();
            sample.Add(0, 0);
            sample.Add(100, 100);
            sample.Add(x, y);
            LinearRegressionFitResult result = sample.LinearRegression();
When it returns, result will contain data about the best-fit line and goodness of fit.

If you are looking for analytic formulas for a and b as functions of x and y, you won't get that from a numerical library. But it's not hard to derive such a formula using the formulas for a and b as functions of input points that you can find in any textbook that covers linear regression.