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
Parameter | Type | Default value | Description |
---|---|---|---|
lookahead | number | undefined | This calculator's lookahead time. |
valueSmoothingTau | number | 0 | The 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 . |
trendSmoothingTau | number | 0 | The 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
):null
|number
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
Parameter | Type | Default value | Description |
---|---|---|---|
smoothed | boolean | false | Whether 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.
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
Parameter | Type | Default value | Description |
---|---|---|---|
value | number | undefined | The new input value. |
dt | number | undefined | The elapsed time since the last input value was added. |
smoothed | boolean | false | Whether 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
Parameter | Type | Description |
---|---|---|
value | number | The new input value. |
dt | number | The 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 null | number |
Parameters
Parameter | Type | Description |
---|---|---|
value | T | The new initial input value. |
Returns
T
The reset lookahead value, which will be equal to the initial input value.
Call Signature
reset(
value?
):null
|number
Defined in: src/sdk/math/Lookahead.ts:119
Resets the "history" of this calculator and optionally sets the initial input value.
Parameters
Parameter | Type | Description |
---|---|---|
value? | null | number | The new initial input value. Defaults to null. |
Returns
null
| number
The reset lookahead value, which will be equal to the initial input value.