Documentation
¶
Overview ¶
Package detmath is the arithmetic of the learner model that package math would give differently on different builds: exp, log, the logistic function σ, a power and the retention of a skill. It gives the same bits on every build of the gc compiler — every architecture, GOAMD64 level and processor, WebAssembly included — so that the state the model folds from the log is the same wherever it is computed.
exp and log are a port of the pure Go code of package math (port.go), which math.Exp and math.Log run on wasm and 386 but not where they have assembler of their own. Every function here keeps its argument within bounds, so that its result is finite and never subnormal: no NaN and no infinity comes out of it, whatever comes in. The engine may take this package as it is.
Index ¶
Constants ¶
const RetentionFactor = 19.0 / 81
RetentionFactor is F in the retention R = 1 / √(1 + F · Δt / τ): 0.9^(−1/C) − 1 at C = 1/2, 19/81, so that the retention after a pause of τ is 0.9.
Variables ¶
This section is empty.
Functions ¶
func Exp ¶
Exp returns e**x for x within [-708, 708], and the value at the nearer bound outside it; NaN gives the value at -708.
func Log ¶
Log returns the natural logarithm of x for x within the positive normal numbers, from 2**-1022 to the largest float64, and the value at the nearer bound outside them: 0, a negative x, a subnormal and NaN give log(2**-1022), +Inf gives the log of the largest float64.
func Pow ¶
Pow returns a**s as e**(s · ln a), with a kept within the bounds of Log, s within the finite floats and s · ln a within the bounds of Exp; NaN goes to the lower bound of each. Its two exact branches keep the rules built on it exact at their ends: a**0 is 1 and a**1 is a. With both kept finite, s · ln a is never 0 · ∞: 1**s is 1 for every s.
func Retention ¶
Retention returns R(Δt, τ) = 1 / √(1 + F · Δt / τ), the retention of a skill dt days after its last practice, at stability tau days. dt is kept within [0, the largest float64], so that a negative dt — a time that came back — and NaN give the retention right after practice, 1; tau is kept within the positive normal numbers, so that 0, a negative tau and NaN give the stability of 2**-1022 days, and the retention of any pause after practice almost 0; and F · Δt / τ is kept below the largest float64, so that the result is normal.
Types ¶
This section is empty.