oracular / predict
Function: predict()
ts
function predict(
state,
intent,
at,
opts?
): Prediction;Defined in: predict.ts:29
The intent's current estimate at time at: the Beta mean p, its standard deviation, the lower confidence bound that shouldReveal tests, and the cooldown status. Read-only: the stored state is decayed to at for the reading but not changed.
Parameters
| Parameter | Type | Description |
|---|---|---|
state | EngineState | The current state. Not mutated. |
intent | string | Name of an intent declared in the config. |
at | number | The time to evaluate at, in the same unit as your durations. |
opts? | RevealOptions | Overrides for threshold, z, cooldown and bound, resolved as call → intent → engine → defaults. z and bound set lower; cooldown sets revealed and suppressedUntil; threshold only matters to shouldReveal. |
Returns
The prediction. p, sd, lower and confidence are in [0, 1]; evidence is α + β.
Throws
RangeError when intent is not declared in the config.
Throws
TypeError when state is not an engine state, at is not finite, or opts is malformed.
Example
ts
const { p, lower, suppressedUntil } = predict(state, 'upgrade', Date.now());
if (suppressedUntil !== null) scheduleNextCheck(suppressedUntil);