rng

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package rng provides deterministic random number generation with hierarchical seed derivation.

The Derive function creates child seeds from parent seeds using FNV-1a hashing, enabling reproducible randomness across nested contexts (entity → field → row). This ensures that the same plan with the same root seed always produces identical output, which is critical for Apery's determinism guarantees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rng

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

Rng is a seeded random number generator

func New

func New(seed Seed) *Rng

New creates a new RNG with a seed.

func (*Rng) Float64

func (r *Rng) Float64() float64

Float64 returns a random float in [0,1.0)

func (*Rng) FloatRange

func (r *Rng) FloatRange(min float64, max float64) float64

FloatRange returns a random float64 in [min, max]

func (*Rng) GetSeed

func (r *Rng) GetSeed() Seed

GetSeed returns rng seed

func (*Rng) IntRange

func (r *Rng) IntRange(min int64, max int64) int64

IntRange returns a random int64 in [min, max]

func (*Rng) Intn

func (r *Rng) Intn(n int) int

Intn returns a random int in [0,n)

func (*Rng) NewZipf

func (r *Rng) NewZipf(s float64, v float64, imax uint64) *rand.Zipf

NewZipf creates a Zipf generator with skewness s, offset v, and max value imax. s must be > 1, v must be >= 1

func (*Rng) NormFloat64

func (r *Rng) NormFloat64() float64

NormFloat64 returns a normally distributed float64 with mean 0 and stddev 1 using the Box-Muller transform

func (*Rng) Read

func (r *Rng) Read(p []byte) (int, error)

Read fills p with random bytes, implementing io.Reader

type Seed

type Seed uint64

Seed represents a deterministic RNG seed.

func Derive

func Derive(parent Seed, label string) Seed

Derive creates a child seed from parent + label.

func DeriveIndex

func DeriveIndex(parent Seed, index int64) Seed

DeriveIndex creates a child seed from parent + index.

func SeedFromInt64

func SeedFromInt64(value int64) Seed

SeedFromInt64 converts an int64 seed into a Seed.

Jump to

Keyboard shortcuts

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