dotnetCHARTING Send comments on this topic.
AddSumOfNonLinearPowerTerms Method
See Also 
dotnetCHARTING Namespace > ForecastEngine.Options Class : AddSumOfNonLinearPowerTerms Method


powerCoefficients
An array where the k-th term is the coefficient of the (k+1)-th term of the sum of power terms (i.e. rk+1).
coefficients
An array where the k-th term is the coefficient of the (space) variable of the argument of the power term (i.e. bk).
constants
An array where the k-th term is the constant shift in the x-axis of the power term of the (k+1)-th term of the sum of power terms (i.e. ck).
exponents
An array where the k-th term is the exponent and the variable of the (k+1)-th power term (i.e. pk+1).
Adds a sum of power terms as an element of the function basis.

Syntax

Visual Basic (Declaration)  
Public Shared Sub AddSumOfNonLinearPowerTerms( _
   ByVal powerCoefficients() As Double, _
   ByVal coefficients() As Double, _
   ByVal constants() As Double, _
   ByVal exponents() As Double _
) 
Visual Basic (Usage) Copy Code
Dim powerCoefficients() As Double
Dim coefficients() As Double
Dim constants() As Double
Dim exponents() As Double
 
ForecastEngine.Options.AddSumOfNonLinearPowerTerms(powerCoefficients, coefficients, constants, exponents)
C#  
public static void AddSumOfNonLinearPowerTerms( 
   double[] powerCoefficients,
   double[] coefficients,
   double[] constants,
   double[] exponents
)

Parameters

powerCoefficients
An array where the k-th term is the coefficient of the (k+1)-th term of the sum of power terms (i.e. rk+1).
coefficients
An array where the k-th term is the coefficient of the (space) variable of the argument of the power term (i.e. bk).
constants
An array where the k-th term is the constant shift in the x-axis of the power term of the (k+1)-th term of the sum of power terms (i.e. ck).
exponents
An array where the k-th term is the exponent and the variable of the (k+1)-th power term (i.e. pk+1).

Remarks

The sum of power terms will take the follow form:

f(x, a0, a1, a2,..., a3n+2) = (r0 * a0 * (a1 * b0 * x + c0 + a2)p0) + ... + (rn * a3n * (a3n+1 * bb * x + cn + a3n+2)pn),

where r0,..., rn, b0,..., bn, c0,..., cn, p0,..., pn are arbitrary real numbers, a0,..., a3n+2 are real numbers corresponding to values of the model parameters and x is a real variable.

Remark: The sum of power terms for the non-linear factor model is a direct generalization of the sum of power terms contained within the General Linear Factor model (see GeneralLinearFactorModel).

Example

In order to clarify the use of this method we provide the following explicit example. In order to set the following term to an instance of the non-linear factor model:

f(x, a0, a1, a2) = 2 * a0 * (a1 * 1 * x + a2 + 0)3,

you must make a call to this method with the parameters:

  1. powerCoefficients = {2}
  2. coefficients = {1}
  3. constants = {0}
  4. exponents = {3}

Using this method to represent a constant function term

You are able to represent the constant function term:

f(x, a0) = a0 * constant,

by calling this method with the parameters constant, coefficients being an array of length 1, where the elements can take any (non-zero) value and powerCoefficients = {constant}, exponents = {0}. However in such an instance care must be taken to observe that in fact you are representing the constant functions using the sum of power terms convension in which:

f(x, a0, a1, a2) = constant * a1 (a1 * x + a2)0 = constant * a1

In particular, you will need to keep track of the model parameters a1 and a2 above when calling methods such as GetValueAt, in which you will need to provide (in fact any) values for a1 and a2.

Worked Example

We considered the function:

f(x, a0, a1,..., a8) = a0(a1x + a2) + a3(a4x + a5)2 + (2.5)a6(a7a0 + a8)0,

which can be set to an instance of this class by calling this method with the parameters:

  1. logCoeffs = { 1.0, 1.0, 2.5 }
  2. coefficients = { 1.0, 1.0, 1.0 }
  3. constants = { 0.0, 0.0, 1.0 }
  4. exponents = { 1.0, 2.0, 0.0 }

Therefore, for example when { a0, a1, ..., a8 } = { 1, 1, 1, 1, 1, 1, 1, 1 }, and evaluate the derivative and function itself using GetValueAt we find that:

x = 0 x = 1 x = 2
∂f/∂a0 = a0x + a1 1 2 3
∂f/∂a1 = a0x 0 1 2
∂f/∂a2 = a0 1 1 1
∂f/∂a3 = (a4x + a5)2 1 4 9
∂f/∂a4 = 2 a3(a4x + a5)x 0 4 12
∂f/∂a5 = 2a3(a4x + a5) 2 4 6
∂f/∂a6 = 2.5 2.5 2.5 2.5
∂f/∂a7 = 0 0 0 0
∂f/∂a8 = 0 0 0 0
f 4.5 8.5 14.5

Source Code Implementation: You can find the source code implementation of this example within the QAExample's within the Client/QAClients/ directory. In particular, this worked example corresponds to the example within the CurveFitting/NonLinearFunctionModel directory of the QAExamples. Note that within this implementation we construct the function described above by calling this method twice where the 1st method call defines to the sub-function which depends on (x, a0, ..., a5), and the 2-nd method call defines the constant function which depends on (x, a6, a7, a8).

See Also