seed

package
v0.1.45 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 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 seed gives the bench its numbers: every draw of sim comes from a place of randomness of the module format, a seed and names, by the platform's one generator. spec has the generator's test vectors but no Go code of it, so the place is built here, by Go's own PCG, and the vectors hold it to the format.

Index

Constants

View Source
const (
	CriterionModel  = "model"
	CriterionEngine = "engine"
	CriterionPair   = "pair"
)

The criteria whose choices take held-out sets of their own.

View Source
const (
	Params   = "params"   // the learner's truth
	Calendar = "calendar" // days, sessions and breaks
	Answers  = "answers"  // the first answers of items
	Retries  = "retries"  // the answers after a rung of the ladder or after unreadable
	Attempts = "attempts" // what each attempt holds: shocks, errors, techniques, abandons
	Attempt  = "attempt"  // the seed of each attempt, for the instances of templates
	Choice   = "choice"   // the seed of a choice of engine, if its rule ever draws at random
	Miss     = "miss"     // the author's miss of a task's difficulty
)

The purposes of the places of a virtual learner and of a task.

Variables

View Source
var ErrName = errors.New("seed: a name of a place is empty or holds |")

ErrName is a name of a place the format does not take: an empty one, or one with "|", which separates the names in the text the high word is hashed from.

View Source
var ErrNoConfirmation = errors.New("seed: no held-out set is recorded for the judgement")

ErrNoConfirmation is a judgement whose held-out set is not recorded.

View Source
var ErrNoInstance = errors.New("seed: a template has no instance")

ErrNoInstance is a template with no instance to choose from.

View Source
var ErrNotRecorded = errors.New("seed: no such held-out set is recorded in the decision log")

ErrNotRecorded is a held-out set the decision log has not recorded yet.

View Source
var Working = Set{Seed: 20261107, Experiment: "working"}

Working is the set of working learners: the gate and the decisive runs take the same ones.

Functions

func High

func High(seed uint64, names ...string) (uint64, error)

High gives the high word of the state of the place of seed and names: FNV-1a 64 over the UTF-8 of the seed in decimal followed, for each name, by "|" and the name. The low word is the seed.

func Instance

func Instance(attemptSeed uint64, task string, count int) (int, error)

Instance gives the number of the instance of a template that an attempt takes, as the platform chooses it: below(count) of the place of the attempt's seed with the names template, the task's ID and instance. Nothing else draws from that place. count is the number of the template's instances, numbered from 0.

func Judgement added in v0.1.17

func Judgement(experiment string) (string, bool)

Judgement gives the judgement whose confirmation a held-out set is, if any.

func Learner

func Learner(population string, n int) string

Learner gives the unit of the n-th virtual learner of a population: <population>/<n>.

func Task

func Task(module, task string) string

Task gives the unit of a task of a module: task/<module>/<task>.

Types

type Set

type Set struct {
	Seed       uint64
	Experiment string
}

Set is a set of virtual learners: a seed and the name of its experiment, the first name of every place it draws from. Sets that must stay apart take seeds of their own, as the format bids ("a use that needs streams apart from another's takes a seed of its own").

func Confirmation added in v0.1.17

func Confirmation(judgement string) (Set, error)

Confirmation gives the held-out set a judgement's confirmation runs on, by the judgement's name.

func HeldOut

func HeldOut(criterion string, n int) (Set, error)

HeldOut gives the held-out set of the n-th choice of a criterion: experiment held-out-<criterion>-<n>, at the seed the decision log recorded for it.

func Named

func Named(experiment string) (Set, error)

Named gives a set by the name of its experiment: working, or a held-out set the decision log has recorded.

func (Set) Place

func (s Set) Place(unit, purpose string) (*Stream, error)

Place gives the stream of the place of a unit and a purpose in the set: names experiment, unit and purpose, as standalone's seeded(unit, purpose) is.

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

Stream is the stream of draws of one place of randomness. The format's five functions are its methods, each Go's own method of math/rand/v2 on the same PCG, drawing the same integers in the same order.

func New

func New(high, low uint64) *Stream

New gives the stream of the generator whose state is high·2^64 + low.

func Place

func Place(seed uint64, names ...string) (*Stream, error)

Place gives the stream of the place of seed and names, at least one.

func (*Stream) Below

func (s *Stream) Below(bound uint64) uint64

Below draws an integer from 0 to bound − 1: the format's below, Go's Uint64N. bound is above 0.

func (*Stream) Between

func (s *Stream) Between(a, c int64) int64

Between draws an integer from a to c, both included: the format's between, a + Int64N(c − a + 1). a is not above c, and c − a + 1 fits in an int64.

func (*Stream) Exponential

func (s *Stream) Exponential() float64

Exponential draws a number of the exponential distribution with mean 1: −ln(1 − u) at one fraction u. 1 − u is above 0, since u is below 1.

func (*Stream) Fraction

func (s *Stream) Fraction() float64

Fraction draws a number in [0, 1): the format's fraction, Go's Float64, the low 53 bits of an integer divided by 2^53. Go's Float64 is inlined, and its product could fuse with what its caller does next — 1 − u, or u − 0.5, into one step on arm64 that rounds once —, so the result goes through float64(), which the Go specification makes round ("An explicit floating-point type conversion rounds to the precision of the target type, preventing fusion"). "Go / fma-diff" holds it.

func (*Stream) Integer

func (s *Stream) Integer() uint64

Integer draws an integer of 64 bits: the format's integer, Go's Uint64.

func (*Stream) Normal

func (s *Stream) Normal() float64

Normal draws a number of the standard normal distribution: the inverse of its distribution function at one fraction, by Wichura's algorithm AS 241, PPND16, which is good to about 1e-16. A fraction of exactly 0 — one draw in 2^53 — is taken as 2^−53, the smallest one above it, so the result is finite and the two tails end at the same distance: the largest 1 − u is 2^−53 too.

func (*Stream) Permutation

func (s *Stream) Permutation(n int) []int

Permutation draws an order of 0 … n − 1: the format's permutation, Go's Perm.

Jump to

Keyboard shortcuts

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