Visual Basic (Declaration) | |
---|---|
Public Overloads Shared Function NonLinearModel( _ ByVal seriesName As String, _ ByVal s As Series, _ ByVal deviations As Series, _ ByVal a() As Double, _ ByVal vary() As Boolean _ ) As Series |
Visual Basic (Usage) | ![]() |
---|---|
|
C# | |
---|---|
public static Series NonLinearModel( string seriesName, Series s, Series deviations, double[] a, bool[] vary ) |
Parameters
- seriesName
- The name of the series which will be displayed on the chart, i.e. its label.
- s
- A statistical series.
- deviations
- An array of doubles where the k-th terms corresponding to the weighting given to the model errors associated within the k-th data point.
- a
- The parameters/state of the model.
- vary
- False to indicate the corresponding
modelParameters[k]
is to be held fixed.
This examlpe finds the real valued function of best fit, of the type considered in accordance with the least squares approach. That is, for the functon f, which depends on the parameters (or variables a[]), we find the variables such that:
E = sum_k {(y[k] - f(x[k],a)) / s[k]}^2
is minimal, where:
- x[] - are the domain points, i.e. the points at which the values of the real valued function are evaluated.
- y[] - are the values of the data points at the domain values.
- a[] - the models parameters, that is the variables which the function which is being fitted depends on.
- s[] - the scale (or weight) which is applied to each error. That is, s[k] is the scale applied the error for the k-th data set point.
Remark: The implemention of the function interface, implements two methods which return the value and the gradient of the function f(x,a), and not the functional E given above.
Features of the Algorithm
The algorithm for the non-linear framework finds the local minimum in accordance with the least squares approach. This mean that the initial point given from which the minimum is sort lies within the same basin of attraction of the global minimum. In practice, this means in particularly when a non-linear function with many terms is considered that the initial starting point is very carefully chosen. This is not a consequence of our implementation but the nature of the algorithm and problem at hand. The algorithms is of greedy type and essentially uses an abstraction of calculus based methods in which the best point in a neighbourhood of a point a chosen at each step.
Remark: As a side note, the reason why the linear algorithm work so well is that it is based on a simplex algorithm which is combinatorial in nature.