PowerFit
Advanced Analysis Library Only
AnalysisLibErrType PowerFit (double arrayX[], double arrayY[], double weight[], ssize_t numberOfElements, int fitMethod, double tolerance, double fittedData[], double *amplitude, double *power, double *residue);
Purpose
Fits the data set (x, y) to the power model using the Least Square, Least Absolute Residual, or Bisquare method. The following equation represents the power model:
where a is the amplitude of the model and b is the power. If fitMethod is LEAST_SQUARE, the function finds the amplitude and power of the power model by minimizing the residue as follows:
where | numberOfElements is numberOfElements |
wi is the i-th element of weight | |
fi is the i-th element of fittedData | |
yi is the i-th element of arrayY |
If fitMethod is BISQUARE, the function finds the amplitude and power of the power model by using reweighted least square fitting iteratively, as shown in the following flowchart:
Parameters
Input | ||
Name | Type | Description |
arrayX | double [] | The x value of the data set (x, y). |
arrayY | double [] | The y value of the data set (x, y). If fittedData is NULL, the best fitted array overwrites arrayY. |
weight | double [] | The weight of each data point. If weight is NULL, the function sets all the elements of weight to 1. |
numberOfElements | ssize_t | The length of arrayX, arrayY, and weight. |
fitMethod | int | The fitting method. fitMethod must be one of the following values:
|
tolerance | double | The stop criteria. The function adjusts the amplitude and power iteratively. If the relative difference of residue in two successive iterations is less than tolerance, the function returns the resulting amplitude and power. If tolerance is less than or equal to 0, the function sets tolerance to 0.0001. |
Output | ||
Name | Type | Description |
fittedData | double [] | The y values calculated using the fitted power model. If fittedData is NULL, the best fit array overwrites arrayY. |
amplitude | double | The amplitude of the fitted power model. |
power | double | The power of the fitted power model. |
residue | double | The weighted mean error of the power fit. If fitMethod is LEAST_ABSOLUTE_RESIDUAL, residue is the weighted mean absolute error, as follows:
If fitMethod is LEAST_SQUARE or BISQUARE, residue is the weighted mean square error, as follows:
|
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. |
Additional Information
Library: Advanced Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 8.0 and later