class
Crowbar::PRNG
- Crowbar::PRNG
- Reference
- Object
Overview
High-performance, deterministic 64-bit pseudo-random number generator. Uses Xoshiro256++ seeded via SplitMix64 for uniform statistical properties, long period (2^256 - 1), and complete reproducibility across platforms.
Defined in:
crowbar/prng.crConstructors
Class Method Summary
Instance Method Summary
-
#choice(array : Array(T)) : T forall T
Random element from array
- #choice?(array : Array(T)) : T | Nil forall T
-
#next_u32 : UInt32
Generate next 32-bit unsigned integer
-
#next_u64 : UInt64
Generate next raw 64-bit unsigned integer using Xoshiro256++
-
#rand(max : Int) : Int32
Random integer in [0, max)
-
#rand(range : Range(Int32, Int32)) : Int32
Random integer within inclusive range (e.g.
-
#rand_bool(prob : Float64 = 0.5) : Bool
Returns true with probability p (default 0.5)
-
#rand_float : Float64
Random Float64 in [0.0, 1.0)
-
#rand_log(max_power : Int32 = 14) : Int32
Log-scale random distribution (useful for repeats, burst lengths, and byte counts) Generates values from 1 up to 2^max_power with logarithmic bias towards smaller values
-
#sample(array : Array(T), count : Int32) : Array(T) forall T
Reservoir sample or simple sample
- #seed : UInt64
- #seed=(new_seed : UInt64)
-
#seek(offset : Int) : Nil
Fast-forwards PRNG state by
offsetiterations -
#shuffle(array : Array(T)) : Array(T) forall T
Non-destructive shuffle
-
#shuffle!(array : Array(T)) : Array(T) forall T
Shuffle array in-place (Fisher-Yates) and return it
Constructor Detail
Class Method Detail
Instance Method Detail
Random integer within inclusive range (e.g. 1..10) or exclusive range (e.g. 0...5)
Log-scale random distribution (useful for repeats, burst lengths, and byte counts) Generates values from 1 up to 2^max_power with logarithmic bias towards smaller values
Shuffle array in-place (Fisher-Yates) and return it