Skip to main content

Class: Lookahead

Defined in: src/sdk/math/Lookahead.ts:9

A calculator for lookahead values based on past trends. The calculator accepts a series of input values separated by discrete time intervals, computes a rate of change at each time step, and uses this rate of change to predict what the input value will be at some arbitrary length of time in the future assuming the rate of change remains constant.

Constructors​

Constructor​

new Lookahead(lookahead, valueSmoothingTau, trendSmoothingTau): Lookahead

Defined in: src/sdk/math/Lookahead.ts:26

Constructor.

Parameters​

ParameterTypeDefault valueDescription
lookaheadnumberundefinedThis calculator's lookahead time.
valueSmoothingTaunumber0The smoothing time constant to apply to the calculator's input values before rate of change is computed. A value of 0 is equivalent to no smoothing. Defaults to 0.
trendSmoothingTaunumber0The smoothing time constant to apply to the calculator's computed trend values. A value of 0 is equivalent to no smoothing. Defaults to 0.

Returns​

Lookahead

Properties​

lookahead​

lookahead: number

Defined in: src/sdk/math/Lookahead.ts:26

This calculator's lookahead time.

Methods​

last()​

last(smoothed): number | null

Defined in: src/sdk/math/Lookahead.ts:39

Gets this calculator's last computed lookahead value. The lookahead value is the predicted value of this calculator's input when projected into the future by an amount equal to the lookahead time assuming the current rate of change of the input remains constant.

Parameters​

ParameterTypeDefault valueDescription
smoothedbooleanfalseWhether to retrieve the lookahead value computed using the last smoothed input value instead of the raw input value as the present (t = 0) value. Defaults to false.

Returns​

number | null

This calculator's last computed lookahead value.


lastTrend()​

lastTrend(): number

Defined in: src/sdk/math/Lookahead.ts:48

Gets this calculator's last computed trend value. The trend value is the equal to the rate of change of this calculator's input values multiplied by the lookahead time.

Returns​

number

This calculator's last computed trend value.


next()​

next(value, dt, smoothed): number

Defined in: src/sdk/math/Lookahead.ts:64

Adds a new input value and gets the next lookahead value. The lookahead value is the predicted value of this calculator's input when projected into the future by an amount equal to the lookahead time assuming the current rate of change of the input remains constant.

Parameters​

ParameterTypeDefault valueDescription
valuenumberundefinedThe new input value.
dtnumberundefinedThe elapsed time since the last input value was added.
smoothedbooleanfalseWhether to return the lookahead value computed using the smoothed input value instead of the raw input value as the present (t = 0) value. Note that this argument does not determine whether smoothing is applied for the purposes of calculating rate of change (smoothing is always applied for this purpose if a positive time constant is defined). Defaults to false.

Returns​

number

The next lookahead value.


nextTrend()​

nextTrend(value, dt): number

Defined in: src/sdk/math/Lookahead.ts:99

Adds a new input value and gets the next trend value. The trend value is the equal to the rate of change of this calculator's input values multiplied by the lookahead time.

Parameters​

ParameterTypeDescription
valuenumberThe new input value.
dtnumberThe elapsed time since the last input value was added.

Returns​

number

The next trend value.


reset()​

Call Signature​

reset(): null

Defined in: src/sdk/math/Lookahead.ts:107

Resets the "history" of this calculator and sets the initial input value to null.

Returns​

null

Call Signature​

reset<T>(value): T

Defined in: src/sdk/math/Lookahead.ts:113

Resets the "history" of this calculator and sets the initial input value.

Type Parameters​
Type Parameter
T extends number | null
Parameters​
ParameterTypeDescription
valueTThe new initial input value.
Returns​

T

The reset lookahead value, which will be equal to the initial input value.

Call Signature​

reset(value?): number | null

Defined in: src/sdk/math/Lookahead.ts:119

Resets the "history" of this calculator and optionally sets the initial input value.

Parameters​
ParameterTypeDescription
value?number | nullThe new initial input value. Defaults to null.
Returns​

number | null

The reset lookahead value, which will be equal to the initial input value.