detmath

package
v0.1.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func Exp(x float64) float64

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

func Log(x float64) float64

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

func Pow(a, s float64) float64

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

func Retention(dt, tau float64) float64

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.

func Sigmoid

func Sigmoid(x float64) float64

Sigmoid returns the logistic function σ(x) = 1 / (1 + e**(−x)) for x within the bounds of Exp, and the value at the nearer bound outside them; NaN gives the value at -708. It lies within [3.3e-308, 1], and is exactly 1 from x ≈ 36.7 up.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL