sampling⚓︎
Random draws for PET: which stream they come from, and the sampler that makes them.
Every draw PET makes -- prior realisations, perturbed observations, outlier
and crash replacement, the auto-adaptive localization's shuffle, popt's
control perturbations -- goes through the ensemble's rng. That is a
numpy.random.RandomState seeded from the ensemble config's seed when
one is given, so a run is reproducible on its own and leaves NumPy's global
state untouched; without a seed it is :class:GlobalRandomStream, which
draws from the global functions exactly as PET always did, so
np.random.seed(...) keeps controlling a run.
GlobalRandomStream
⚓︎
NumPy's global random functions behind a RandomState-shaped object.
Exists for two reasons: the numpy.random module itself cannot be
pickled, and the ensemble is pickled by its emergency dump; and a named
object makes it visible in code that a draw comes from the global stream.
choice(a, size=None, replace=True, p=None)
⚓︎
As numpy.random.choice, on the global stream.
get_state()
⚓︎
As numpy.random.get_state, on the global stream.
multivariate_normal(mean, cov, size=None)
⚓︎
As numpy.random.multivariate_normal, on the global stream.
normal(loc=0.0, scale=1.0, size=None)
⚓︎
As numpy.random.normal, on the global stream.
permutation(x)
⚓︎
As numpy.random.permutation, on the global stream.
rand(*shape)
⚓︎
As numpy.random.rand, on the global stream.
randn(*shape)
⚓︎
As numpy.random.randn, on the global stream.
set_state(state)
⚓︎
As numpy.random.set_state, on the global stream.
standard_normal(size=None)
⚓︎
As numpy.random.standard_normal, on the global stream.
uniform(low=0.0, high=1.0, size=None)
⚓︎
As numpy.random.uniform, on the global stream.
gen_real(mean, var, number, rng=None, limits=None, return_chol=False)
⚓︎
Realisations of a Gaussian with the given mean and (co)variance.
Draw for draw the same as geostat.decomp.Cholesky.gen_real -- the
same shapes drawn in the same order with the same arithmetic -- so runs
are bit-identical to what geostat produced; only the stream is a
parameter now.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean
|
(array - like, shape(n))
|
Mean vector. |
required |
var
|
array - like
|
Variance vector |
required |
number
|
int
|
Number of realisations. |
required |
rng
|
RandomState - like
|
The stream to draw from; the global one by default. |
None
|
limits
|
dict
|
|
None
|
return_chol
|
bool
|
Also return the factor used: |
False
|
Returns:
| Type | Description |
|---|---|
ndarray, shape (n, number), and the factor when ``return_chol``.
|
|
random_stream(seed=None)
⚓︎
The stream a run draws from: a private RandomState if seed is given, else the global one.