Approximation2D (FPScript)

21.09.2021

Approximates a linear model Y(X, Z) with two independent variables to given 2D data according to the method of the least square error.

Syntax

Approximation2D(DataSet, Model)
or
Approximation2D(DataSet, CustomModel)

 

The syntax of the Approximation2D function consists of the following parts:

Part

Description

DataSet

The data set whose approximation is calculated. If you specify a data series or a data matrix, then the X and Z components will be generated automatically.

Permitted data structures are data series, data matrix, signal, signal series und space curve. All numeric data types are permitted.

For complex data types the absolute value is formed.

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

Model

Specifies the composition of the model function whose coefficients are determined by the approximation.

The argument Model can have the following values:

The argument Model can be formed by adding the following values. For example, if the desired model function is A + B * X + C * Z2, then the Model argument must receive the value APPROX2D_C + APPROX2D_X + APPROX2D_Z_2. Approximation2D then calculates the unknown coefficients A, B and C so that the model function approximates the specified signal as best as possible.

Constant

Meaning

+ APPROX2D_C

1

+ APPROX2D_X

X

+ APPROX2D_X_2

X2

+ APPROX2D_X_3

X3

+ APPROX2D_X_REC

1/X

+ APPROX2D_X_REC2

1/X2

+ APPROX2D_X_EXP

eX

+ APPROX2D_X_EXP2

eX

+ APPROX2D_X_LN

log(X)

+ APPROX2D_X_LOG

log10(X)

+ APPROX2D_X_POW

10X

+ APPROX2D_X_POW2

10X

+ APPROX2D_X_SQRT

sqrt(X)

+ APPROX2D_Z

Z

+ APPROX2D_Z_2

Z2

+ APPROX2D_Z_3

Z3

+ APPROX2D_Z_REC

1/Z

+ APPROX2D_Z_REC2

1/Z2

+ APPROX2D_Z_EXP

eZ

+ APPROX2D_Z_EXP2

eZ

+ APPROX2D_Z_LN

log(Z)

+ APPROX2D_Z_LOG

log10(Z)

+ APPROX2D_Z_POW

10Z

+ APPROX2D_Z_POW2

10Z

+ APPROX2D_Z_SQRT

sqrt(Z)

+ APPROX2D_XZ

X*Z

+ APPROX2D_XZ_2

(X*Z)2

+ APPROX2D_XZ_REC

1/(X*Z)

Permitted data structures are scalar value. Supported data types are 16-bit integer und 32-bit integer.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

CustomModel

Specifies the composition of the model function whose coefficients are determined by the approximation. The custom model function is passed as a data series of strings. For instance, the model function Y = A + B * X + C * sin(2 * PI * Z) is described by the data series {"1", "X", "sin(2*PI*Z)"}.

Permitted data structures are data series. Supported data types are string.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Remarks

As the result the function returns a data series of data type 64-bit floating point.

The number of values equals to the number of element functions of the model function plus one.

The last value represents the goodness-of-fit measure Χ2 (Chi-square). This is the sum of the squares of all deviations of the approximated model function from the data. The smaller Χ2 is, the better the found model function approximates the data. The other values of the data series provide the coefficients of the element functions used in the model function, where the order corresponds to the order in the table above.

Available in

FlexPro Basic, Professional, Developer Suite

Examples

Dim _c = Approximation2D(SpaceCurve, APPROX2D_C + APPROX2D_X + APPROX2D_Z_2)
Signal(_c[0] + _c[1] * (SpaceCurve.X) + _c[2] * (SpaceCurve.Z)^2., SpaceCurve.X, SpaceCurve.Z)
 

Approximates a space curve with a quadratic model function Y(X, Z) = A + B * X + C * Z2.

See Also

Approximation Function

HarmonicEstimation Function

NonLinCurveFit Function

Approximation Analysis Object

2D Approximation Analysis Object

Linear Regression Analysis Object

References

[1] "Philip R. Bevington, D. Keith Robinson": "Data Reduction and Error Analysis for the Physical Sciences, 3rd Edition". "McGraw-Hill, New York",2003.ISBN 0-07-247227-8.

[2] "William H. Press et al.": Numerical Recipes in C, Second Edition. "Cambridge University Press",1992.ISBN 0-552-43108-5.

Share article or send as email:

You might be interested in these articles