Skip to main content

Class: Lookahead

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

Constructor.

Parameters

NameTypeDefault 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

Defined in

src/sdk/math/Lookahead.ts:26

Properties

lookahead

lookahead: number

This calculator's lookahead time.

Defined in

src/sdk/math/Lookahead.ts:26

Methods

last

last(smoothed?): null | number

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

NameTypeDefault 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

null | number

This calculator's last computed lookahead value.

Defined in

src/sdk/math/Lookahead.ts:39


lastTrend

lastTrend(): number

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.

Defined in

src/sdk/math/Lookahead.ts:48


next

next(value, dt, smoothed?): number

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

NameTypeDefault 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.

Defined in

src/sdk/math/Lookahead.ts:64


nextTrend

nextTrend(value, dt): number

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

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

Returns

number

The next trend value.

Defined in

src/sdk/math/Lookahead.ts:99


reset

reset(): null

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

Returns

null

Defined in

src/sdk/math/Lookahead.ts:107

reset<T>(value): T

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

Type parameters

NameType
Textends null | number

Parameters

NameTypeDescription
valueTThe new initial input value.

Returns

T

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

Defined in

src/sdk/math/Lookahead.ts:113

reset(value?): null | number

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

Parameters

NameTypeDescription
value?null | numberThe new initial input value. Defaults to null.

Returns

null | number

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

Defined in

src/sdk/math/Lookahead.ts:119