ExpFit

Advanced Analysis Library Only

AnalysisLibErrType ExpFit (double arrayX[], double arrayY[], int numberOfElements, double outputArray[], double *amplitude, double *decay, double *meanSquaredError);

Purpose

Note  This function is obsolete. National Instruments recommends that you use ExpFitEx instead.

Finds the coefficient values that best represent the exponential fit of the data points (X, Y) using the least squares method. ExpFit obtains the element of the output array using the following formula:

Zi = aedXi

where a = amplitude
d = decay
i = array index

ExpFit obtains the mean squared error using the following formula:


where n is the number of sample points.

ExpFit can perform this operation in place; that is, the input and output arrays can be the same.

Example

/* Generate an exponential pattern and find the best exponential fit. */
double x[200], y[200], z[200];
double first, last, a, b, amp, decay, mse;
n;
n = 200;
first = 0.0;
last = 1.99E2;
Ramp (n, first, last, x); /* x[i] = i */
a = 3.5;
b = -2.75;
for (i=0; i<n; i++)

y[i] = a * exp(b*x[i]);

/* Find the best exponential fit in z. */
ExpFit (x, y, n, z, &amp, &decay, &mse);

Note    The y values must be all positive or all negative to perform an exponential fit.

Parameters

Input
Name Type Description
arrayX double-precision array An array whose elements contain the X coordinates of the (X,Y) data sets.
arrayY double-precision array An array whose elements contain the Y coordinates of the (X,Y) data sets.
numberOfElements integer Number of sample points used in the exponential fit operation.
Output
Name Type Description
outputArray double-precision array Best exponential fit.
amplitude double-precision Value that best describes the amplitude of the exponential curve.
decay double-precision Decay value that best describes the exponential curve.
meanSquaredError double-precision The mean squared error generated by the difference between the fitted curve and the raw data.

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.