dotnetCHARTING Send comments on this topic.
TrendLinePolynomial(SeriesCollection,Int32,Double,Int32,Int32) Method
See Also 
dotnetCHARTING Namespace > ForecastEngine Class > TrendLinePolynomial Method : TrendLinePolynomial(SeriesCollection,Int32,Double,Int32,Int32) Method


sc
A collection of series objects. For example, to evaluate this indicator for two series you will need to pass a series collection containing this two series.
degree
The degree of the polynomial which is fitted to the data set given (i.e. if degree is 2, then a quadratic is fitted).
step
The distance in the x-coordinate between two adjacent extended points. Please note that this also corresponds to the distance in the x-coordinate between the highest and lowest original data point and the first (above or below) additional evaluation point.
forward
The number of additional evaluation points which are evaluated above the x-coordinates of the original given data set.
backward
The number of additional evaluation points which are evaluated below the x-coordinates of the original given data set.
Fits a polynomial of a given degree to a data set in accordance with the least squares approach and returns the value of the fitted function over an extended (i.e. above, below or both) range of the x-coordinate values of the given data set.

Syntax

Visual Basic (Declaration) 
Overloads Public Shared Function TrendLinePolynomial( _
   ByVal sc As SeriesCollection, _
   ByVal degree As Integer, _
   ByVal step As Double, _
   ByVal forward As Integer, _
   ByVal backward As Integer _
) As SeriesCollection
Visual Basic (Usage)Copy Code
Dim sc As SeriesCollection
Dim degree As Integer
Dim step As Double
Dim forward As Integer
Dim backward As Integer
Dim value As SeriesCollection
 
value = ForecastEngine.TrendLinePolynomial(sc, degree, step, forward, backward)
C# 
public static SeriesCollection TrendLinePolynomial( 
   SeriesCollection sc,
   int degree,
   double step,
   int forward,
   int backward
)

Parameters

sc
A collection of series objects. For example, to evaluate this indicator for two series you will need to pass a series collection containing this two series.
degree
The degree of the polynomial which is fitted to the data set given (i.e. if degree is 2, then a quadratic is fitted).
step
The distance in the x-coordinate between two adjacent extended points. Please note that this also corresponds to the distance in the x-coordinate between the highest and lowest original data point and the first (above or below) additional evaluation point.
forward
The number of additional evaluation points which are evaluated above the x-coordinates of the original given data set.
backward
The number of additional evaluation points which are evaluated below the x-coordinates of the original given data set.

Return Value

A series where the k-th element of the array represents of k-th point (i.e. { x_k, y_k }) of the total set over which the fitted function is evaluated. The total set over which the fitted function is evaluated consists of the `backward' points, original data set points and the `forward' points.

Remark: This methods corresponds in functionality to the method of the same name within Microsoft Excel.

Remarks

For example, if we fit a polynomial of degree 2, then we fit the quadratic polynomial (i.e. f(x) = a_0 + a_1 x + a_2 x^2); similarly if we fit a polynomial of degree 3, then we fit the cubic polynomial (i.e. f(x) = a_0 + a_1 x + a_2 x^2 + a_3 x^3).

Remark: The difference between this method and TrendLinePolynomial, is that it allows the values of the fitted function to be evaluated over an extended range. That is, a range in the x-coordinate greater than the original given data set.

Where the extended values are evaluated?

The parameters step, forward, backward allows the position and number of additional points above and/or below the range of the values in the x-coordinate of the original data set to be given. The forward parameter specifies the number of the additional evaluation points of the fitted function which are greater than the values of the x-coordinates of the original data set. Similarly, the backward parameter specifies the number of the additional evaluation points of the fitted function which are lower than the values of the x-coordinates of the original data set. The step specifies the distance in the x-coordinate between each of the additional data points, where the first additional data point either above or below is exactly a distance of step from the points of the original data set which the highest and lowest values in the x-coordinate.

For example, consider the data set x = 1, 2, 3; y = 1, 2, 3. Now if step = 1, forward = 2, and backward = 3, then this method when applied will return a two dimensional array. This two dimensional array will have the following structure: { { -2, f(-2) } { -1, f(-1) } { 0, f(0) }{ 1, 1 } { 2, 2 }{ 3, 3 } { 4, f(4) } { 5, f(5) } }, where f(-2), f(-1), f(0), f(4), f(5) correspond to the value of the fitted functions at the points x = -2, -1, 0, 4, 5, respectively.

See Also