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) = ∑^{n}_{i=0}[y_{i}  f(x_{i};α]^{2} =
∑^{n}_{i=0}(y_{i}  a  bx_{i})^{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());
}
