Show contents 

Stat Assembly > Stat Assembly Interfaces > IStatistics > IStatistics.Forecast

IStatistics.Forecast

Syntax

Forecast(Value: Double; KnownYs: Array; KnownXs: Array): Double;

Parameters

Value. Index of the point whose value is predicted;

KnownYs. Dependent array of data;

KnownXs. Independent array of data.

NOTE. KnownYs and KnownXs must not be empty and must contain equal number of points.

Description

The Forecast method calculates a future value by existing values.

Comments

Predicted value is a Y value corresponding to specified X value. Known values are the KnownYs value and the KnownXs value and a new value is predicted using the linear regression.

Example

To execute the example, add a link to the Stat system assembly.

Sub UserProc;
Var
    st: Statistics;
    d0: Double;
    y, x: Array Of Double;
Begin
    y := New Double[10];
    x := New Double[10];
    y[00] := 1.6; x[00] := 2;
    y[01] := 1.7; x[01] := 4;
    y[02] := 1.8; x[02] := 2;
    y[03] := 1.9; x[03] := 5;
    y[04] := 2; x[04] := 12;
    y[05] := 2.1; x[05] := 6;
    y[06] := 2.2; x[06] := 15;
    y[07] := 2.3; x[07] := 17;
    y[08] := 2.4; x[08] := 14;
    y[09] := 2.8; x[09] := 3;
    st := New Statistics.Create;
    d0 := st.Forecast(30,y,x);
    If st.Status <> 0 Then
        Debug.WriteLine(st.Errors);
    Else
        Debug.WriteLine("Forecast: " + d0.ToString);
    End If;
End Sub UserProc;

Executing the example shows a forecast value in the console window:

Unit execution started

Forecast: 2.60857142857143

Unit execution finished

See also:

IStatistics | Linear regression