Least-square method
Let us have the set of values yi, every one of which corresponds to any moment of time ti(i=1,2,…,N). We need to find dependency y=f(t), if the sum of squared divergences of points of curve from the appropriate point yi is the minimal in the class of approximating functions. That is
(1)i=1∑n(f(ti)−yi)2→minWe will find the solution in the class of the linear functions (straight lines): y=at+b. Then the term (1) we can write as the following
i=1∑n(a∗ti+b−yi)2→minThe necessary condition of the existence of minimum is the equality to zero of two partial derivatives on a and b accordingly:
i=1∑n((a∗ti+b−yi)∗ti)=0i=1∑n(a∗ti+b−yi)=0In designations
i=1∑nti2=stti=1∑n(yi∗ti)=syti=1∑n(ti)=sti=1∑n(yi)=syNoting that
i=1∑nb=b∗N,the system can be rewritten as the following
a∗stt+b∗st−syt=0a∗st+b∗N−sy=0Solving this system of two linear equations for a and b we will get
a=(syt∗N−sy∗st)/(N∗stt−st∗st)b=(stt∗sy−syt∗st)/(N∗stt−st∗st)