modea.Sampling module¶
This module contains several sampling options that can be used when drawing random values for mutations.
Some of the sampling options in this module can be considered base-samplers. This means that they produce a set
of values without requiring any input. The remaining options will have a base_sampler optional argument, as they
need input from some other sampler to produce values, as they perform operations on them such as mirroring.
Indirect samplers¶
-
class
modea.Sampling.GaussianSampling(n, shape='col')¶ Bases:
objectA sampler to create random vectors using a Gaussian distribution
Parameters: - n – Dimensionality of the vectors to be sampled
- shape – String to select between whether column (
'col') or row ('row') vectors should be returned. Defaults to column vectors.
-
next()¶ Draw the next sample from the Sampler
Returns: A new vector sampled from a Gaussian distribution with mean 0 and standard deviation 1
-
class
modea.Sampling.MirroredOrthogonalSampling(n, lambda_, shape='col', base_sampler=None)¶ Bases:
objectFactory method returning a pre-defined mirrored orthogonal sampler in the right order: orthogonalize first, mirror second.
Parameters: - n – Dimensionality of the vectors to be sampled
- shape – String to select between whether column (
'col') or row ('row') vectors should be returned. Defaults to column vectors - base_sampler – A different Sampling object from which samples to be mirrored are drawn. If no
base_sampler is given, a
GaussianSamplingobject will be created and used.
Returns: A
MirroredSamplingobject with as base sampler anOrthogonalSamplingobject initialized with the given parameters.-
next()¶ Draw the next sample from the Sampler
Returns: A new vector, alternating between a new orthogonalized sample from the base_sampler and a mirror of the last.
-
reset()¶ Reset the internal state of this sampler, so the next sample is forced to be taken new.
-
class
modea.Sampling.MirroredSampling(n, shape='col', base_sampler=None)¶ Bases:
objectA sampler to create mirrored samples using some base sampler (Gaussian by default) Returns a single vector each time, while remembering the internal state of whether the
next()should return a new sample, or the mirror of the previous one.Parameters: - n – Dimensionality of the vectors to be sampled
- shape – String to select between whether column (
'col') or row ('row') vectors should be returned. Defaults to column vectors - base_sampler – A different Sampling object from which samples to be mirrored are drawn. If no
base_sampler is given, a
GaussianSamplingobject will be created and used.
-
next()¶ Draw the next sample from the Sampler
Returns: A new vector, alternating between a new sample from the base_sampler and a mirror of the last.
-
reset()¶ Reset the internal state of this sampler, so the next sample is forced to be taken new.
-
class
modea.Sampling.OrthogonalSampling(n, lambda_, shape='col', base_sampler=None)¶ Bases:
objectA sampler to create orthogonal samples using some base sampler (Gaussian as default)
Parameters: - n – Dimensionality of the vectors to be sampled
- lambda – Number of samples to be drawn and orthonormalized per generation
- shape – String to select between whether column (
'col') or row ('row') vectors should be returned. Defaults to column vectors - base_sampler – A different Sampling object from which samples to be mirrored are drawn. If no
base_sampler is given, a
GaussianSamplingobject will be created and used.
-
next()¶ Draw the next sample from the Sampler
Returns: A new vector sampled from a set of orthonormalized vectors, originally drawn from base_sampler
-
reset()¶ Reset the internal state of this sampler, so the next sample is forced to be taken new.
-
class
modea.Sampling.QuasiGaussianHaltonSampling(n, shape='col')¶ Bases:
objectA quasi-Gaussian sampler based on a Halton sequence
Parameters: - n – Dimensionality of the vectors to be sampled
- shape – String to select between whether column (
'col') or row ('row') vectors should be returned. Defaults to column vectors
-
next()¶ Draw the next sample from the Sampler
Returns: A new vector sampled from a Halton sequence with mean 0 and standard deviation 1
-
class
modea.Sampling.QuasiGaussianSobolSampling(n, shape='col', seed=None)¶ Bases:
objectA quasi-Gaussian sampler based on a Sobol sequence
Parameters: - n – Dimensionality of the vectors to be sampled
- shape – String to select between whether column (
'col') or row ('row') vectors should be returned. Defaults to column vectors
-
next()¶ Draw the next sample from the Sampler
Returns: A new vector sampled from a Sobol sequence with mean 0 and standard deviation 1