Home Site Statistics  |   Contact  |   About Us       Thursday, July 29, 2021   

j0110924 - Back to Home

Skip Navigation Links.

   Skip Navigation LinksHOME ›  AREAS OF EXPERTISE ›   Curve Fitting  ›  ~ Straight Line Fit

"Curve Fitting Solutions"
Straight Line Fit Method
f(x) =
(constant)  (x)   (standard deviation)

x-array = { , , , , , }
y-array = { , , , , , }

[ Initial x-array: { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 } ]
[ Initial y-array: { 1.9, 2.7, 3.3, 4.4, 5.5, 6.5 } ]

Curve Fitting Linear Fit

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:

f(x;α) = a + bx

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,

α = √ S / n - m

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();
                 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());

As a sample we provide the input data points using two double arrays x-array and y-array. Running this example generates results (1.729, 0.929, 0.191). Therefore, the regression line is given by:

f(x) = 1.729 + 0.929x

and the standard deviation is,


The user can manipulate all values and try variations on the arrays themselves by specifying new estimate values.

Other Implementations...

Object-Oriented Implementation
Graphics and Animation
Sample Applications
Ore Extraction Optimization
Vectors and Matrices
Complex Numbers and Functions
Ordinary Differential Equations - Euler Method
Ordinary Differential Equations 2nd-Order Runge-Kutta
Ordinary Differential Equations 4th-Order Runge-Kutta
Higher Order Differential Equations
Nonlinear Systems
Numerical Integration
Numerical Differentiation
Function Evaluation

Consulting Services - Back to Home

Home Math, Analysis,

Eigen Inverse Iteration
Rayleigh-Quotient Method
Cubic Spline Method


Applied Mathematical Algorithms

Home A complex number z = x + iy, where...

Complex Functions
Home Non-linear system methods...

Non Linear Systems
Home Construction of differentiation...

Home Consider the function where...

About Us

KMP Engineering is an independent multidisciplinary engineering consulting company specializing in mathematical algorithms.

Contact Us

2461 E Orangethorpe Ave Fullerton, CA 92631 USA info@keystoneminingpost.com
Site Map

   Areas of Expertise
   Reference Items
   Managed Services

Mining & Software Engineering

Since 2006 All Rights Reserved  © KMP Engineering LINKS | PRIVACY POLICY | LEGAL NOTICE