mrg32k3a package¶
Submodules¶
mrg32k3a.matmodops module¶
Summary¶
Useful matrix/modulus operations for mrg32k3a generator.
- mrg32k3a.matmodops.mat33_mat33_mod(A, B, m)[source]¶
Compute moduli of a 3 x 3 matrix x 3 x 3 matrix product.
mrg32k3a.mrg32k3a module¶
Summary¶
Provide a subclass of random.Random
using mrg32k3a as the generator
with stream/substream/subsubstream support.
- class mrg32k3a.mrg32k3a.MRG32k3a(ref_seed=(12345, 12345, 12345, 12345, 12345, 12345), s_ss_sss_index=None)[source]¶
Bases:
Random
Implements mrg32k3a as the generator for a
random.Random
object.- ref_seed¶
Seed from which to start the generator. Streams/substreams/subsubstreams are referenced w.r.t.
ref_seed
.
- s_ss_sss_index¶
Triplet of the indices of the current stream-substream-subsubstream.
- Parameters
See also
- advance_stream()[source]¶
Advance the state of the generator to the start of the next stream. Streams are of length 2**141.
- advance_substream()[source]¶
Advance the state of the generator to the start of the next substream. Substreams are of length 2**94.
- advance_subsubstream()[source]¶
Advance the state of the generator to the start of the next subsubstream. Subsubstreams are of length 2**47.
- continuous_random_vector_from_simplex(n_elements, summation=1.0, exact_sum=True)[source]¶
Generate a random vector with a specified number of non-negative real-valued elements that sum up to (or less than or equal to) a specified number.
- Parameters
- Returns
vec – Vector of
n_elements
non-negative real-valued numbers that sum up to (or less than or equal to)summation
.- Return type
- getstate()[source]¶
Return the state of the generator.
- Returns
tuple [int] – Current state of the generator,
_current_state
.tuple [int] – Ouptput of
random.Random.getstate()
.
See also
- integer_random_vector_from_simplex(n_elements, summation, with_zero=False)[source]¶
Generate a random vector with a specified number of non-negative integer elements that sum up to a specified number.
- Parameters
- Returns
vec – A non-negative integer vector of length n_elements that sum to n_elements.
- Return type
- lognormalvariate(lq, uq)[source]¶
Generate a Lognormal random variate using 2.5% and 97.5% quantiles
- mvnormalvariate(mean_vec, cov, factorized=False)[source]¶
Generate a normal random vector.
- Parameters
mean_vec (list [float]) – Location parameters of the multivariate normal distribution from which to generate.
cov (list [list [float]]) – Covariance matrix of the multivariate normal distribution from which to generate.
factorized (bool, default=False) – True if we do not need to calculate Cholesky decomposition, i.e., if Cholesky decomposition is given as
cov
; False otherwise.
- Returns
Multivariate normal random variate from the specified distribution.
- Return type
- random()[source]¶
Generate a standard uniform variate and advance the generator state.
- Returns
u – Pseudo uniform random variate.
- Return type
- reset_subsubstream()[source]¶
Reset the state of the generator to the start of the current subsubstream.