Seed once for reproducible native sampling
Advance one native generator, choose weighted alternatives and replay from a retained seed; use explicit addresses for parallel samples.
// Seed once; every successful sampling call advances this explicit generator.
import aner.random
let rng = random.generator(seed: 20261019) // Omit seed for a fresh OS-derived seed.
print(random.engine())
print("Replay seed: " + String(rng.seed()))
let first = rng.uniform()
print(first)
print(rng.integer(low: 1, high: 10))
print(rng.bernoulli(probability: 0.8))
print(cast<String>(rng.choice(List("tails", "heads"), weights: List(2, 8))))
print(cast<String>(rng.choice(List("N", "E", "W", "S"))))
print(rng.normal(mean: 10.0, stddev: 2.0))
print(rng.weighted_index(weights: List(1, 3)))
let samples = Array<Float64>(size: 8, fill: 0.0)
for index in Range(samples.len()) { samples[index] = rng.uniform() }
print(samples)
print("Next draw: " + String(rng.position()))
rng.reseed(seed: 20261019)
print("Replay first draw: " + String(first == rng.uniform()))
let alias = rng // Shared handle, not a copied sequence.
print(alias.uniform())
print("Shared next draw: " + String(rng.position()))
let fresh = random.generator()
print("Fresh run seed: " + String(fresh.seed()))
print(fresh.uniform())
Make it your experiment.
With Aner 0.0.3 or newer installed, save this program as examples/random_basic.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/random_basic.aner
aner run examples/random_basic.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Use Aner 0.0.3 or newer with aner.random and RandomGenerator. Earlier packaged executables may predate this module. This complete example runs locally with a retained replay seed and no external files, service or credentials. The guide explains owned cursors, addressed draws, distribution domains and numerical replay limits.
Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution