comnum.Rng#
- class comnum.Rng(seed)#
A seeded random generator (xoshiro256** seeded through SplitMix64).
The same generator as the Rust crate: a seed gives the same draws in Rust and in Python. Every function of
comnumthat draws takes one as itsrngargument and advances it.- Parameters:
seed (int) – the seed (any 64-bit unsigned integer).
Examples
>>> import comnum >>> rng = comnum.Rng(1) >>> rng.uniform(3).shape (3,) >>> comnum.Rng(7).next_u64() == comnum.Rng(7).next_u64() True
- static stream(seed, name, condition, trial)#
The generator of trial
trialof conditionconditionof experimentnamederived from a base seed (the streams of the Monte Carlo runner).- Parameters:
- Returns:
an independent generator.
- Return type:
Examples
>>> import comnum >>> a = comnum.Rng.stream(1, "exp", 0, 3).uniform(2) >>> bool((a == comnum.Rng.stream(1, "exp", 0, 3).uniform(2)).all()) True
- complex_noise(n, noise_var=1.0)#
Circular complex Gaussian draws of variance
noise_var(E|w|² = noise_var).- Parameters:
- Returns:
nvalues (complex128).- Return type:
- Raises:
ValueError – for a negative count.
- gaussian(n)#
Standard normal draws.
- Parameters:
n (int) – number of draws.
- Returns:
nvalues (float64).- Return type:
- Raises:
ValueError – for a negative count.
- integers(high, n)#
Uniform integers in
[0, high).- Parameters:
- Returns:
nvalues (int64).- Return type:
- Raises:
ValueError – for an invalid parameter (the message names it).
- uniform(n)#
Uniform draws in
[0, 1).- Parameters:
n (int) – number of draws.
- Returns:
nvalues (float64).- Return type:
- Raises:
ValueError – for a negative count.