class ExplicitEquation : public DataSource
ExplicitEquation represents a generic explicit equation type, that is to say, a function y = f(x1, x2, ..., a1, a2, ...) where y is the dependent variable, x1, x2 are the independent variables and a1, a2, ... are the specific coefficients. For example:
y = 3*x^2 + 2*x - 1
where the numbers 3, 2 and -1 are the equation coefficients.
It can support any explicit equation so it is used to handle trend lines and non linear regression.
Its normal use is subclassed to equation types like LinearEquation, PolynomialEquation, FourierEquation, Rational1Equation, ExponentialEquation, UserEquation.
virtual void SetDegree(int num)
Sets num as the degree of the equation. In a polynomial equation it is the exponent of the highest power of the independent variables.
It is related with the equation number of coefficients as the higher the degree, the higher the number of coefficients and thus the complexity of the equation.
FitError Fit(DataSource &series, double &r2)
Searches for the best combination of coefficients of the equation that matches series data series. The quality of the matching is returned in the coefficient of determination r2.
It uses Eigen implementation of Levenberg-Marquardt algorithm based on Jorge Moré et al. MINPACK original library.
Function returns succesfully. It is a return value bigger than zero.
Only data series sources are supported. Explicit and parametric functions are not supported.
The number of values of the data set has to be bigger or equal than the number of coefficients to be obtained.
There are problems in the input parameters. For example repeated data may avoid convergence.
The methods converges to a solution too slowly.
FitError Fit(DataSource &series)
Simplified version of bool Fit(DataSource &series, double &r2) that do not return r2.
virtual void GuessCoeff(DataSource &series) = 0
Guesses a set of initial values for the equation coefficients that matches series, based on previous knowledge of equation.
virtual double f(double x1)
Returns the value of the explicit equation based on the independent value x.
virtual double f(double x1, double x2)
Returns the value of the explicit equation based on the independent values x1 and x2.
virtual double f(Vector <double> x)
Returns the value of the explicit equation based on the independent value set xn.
virtual String GetName()
Returns the equation name as "Linear", "Polynomial" or "Fourier".
virtual String GetFullName()
Returns the equation name as "Linear", "Polynomial n = 2" or "Fourier n = 3". n represents the degree of the equation.
virtual String GetEquation()
Returns the equation in plain text, as y = -34 + 12*x - 3*x^2
void SetNumDigits(int n)
Sets with n the equation coefficients number of digits when returned by String GetEquation().
Returns the equation coefficients number of digits when returned by String GetEquation().
void SetMaxFitFunctionEvaluations(int n)
Sets with n the maximum number of equation evaluations done by Fit() searching for the best coefficients values.
Returns the maximum number of equation evaluations done by Fit() searching for the best coefficients values.