Imp.Optimizer.Sampling (Imp v0.5.0)

Copy Markdown View Source

Deterministic sampling helpers for optimizers.

Every sampling operation accepts and returns explicit :rand state so optimizer runs remain reproducible without process-global random state.

Summary

Types

state()

@type state() :: :rand.state()

Functions

choose(values, state)

@spec choose([value], state()) :: {value, state()} when value: var

dump(state)

@spec dump(state()) :: map()

Serializes an explicit optimizer RNG state into JSON-safe data.

integer(count, state)

@spec integer(pos_integer(), state()) :: {non_neg_integer(), state()}

load!(value)

@spec load!(map()) :: state()

Restores an optimizer RNG state serialized by dump/1.

new(seed)

@spec new(integer()) :: state()

percentile(values, percentile)

@spec percentile([number()], number()) :: float()

poisson(lambda, state)

@spec poisson(number(), state()) :: {non_neg_integer(), state()}

shuffle(values, state)

@spec shuffle([value], state()) :: {[value], state()} when value: var

softmax_choose(scored, temperature, state)

@spec softmax_choose([{value, number()}], number(), state()) :: {value, state()}
when value: var

uniform(state)

@spec uniform(state()) :: {float(), state()}