The most popular curve fitting technique is the least squares method. The simplest linear regression is the straight line
fit, which attempts to fit a straight line using the least squares technique.
Algorithm Creation
The model function has the following simple form:
where the sum of the linear regression becomes,
S(a,b) = ∑ni=0[yi - f(xi;α]2 =
∑ni=0(yi - a - bxi)2
|
The standard deviation α can be expressed by,
Testing the Straight Line Fit Method
In order to test theStraight Line Fit Method as defined above, a new TestStraightLineFit()
static method has been added and executed. Supporting code and methods are not shown.
static void TestStraightLineFit();
{
ListBox1.Items.Clear();
double[] xarray = new double[] { t1, t2, t3, t4, t5, t6 };
double[] yarray = new double[] { t7, t8, t9, t10, t11, t12 };
double[] x = new double[] { t11, t12, t13, t14 };
double[] results = CurveFitting.StraightLineFit(xarray, yarray);
VectorR v = new VectorR(results);
ListBox1.Items.Add(" " + v.ToString());
}
|