Class ZigguratSampler.NormalizedGaussian
- java.lang.Object
-
- org.apache.commons.rng.sampling.distribution.ZigguratSampler
-
- org.apache.commons.rng.sampling.distribution.ZigguratSampler.NormalizedGaussian
-
- All Implemented Interfaces:
ContinuousSampler
,NormalizedGaussianSampler
,SharedStateContinuousSampler
,SharedStateSampler<SharedStateContinuousSampler>
- Enclosing class:
- ZigguratSampler
public static final class ZigguratSampler.NormalizedGaussian extends ZigguratSampler implements NormalizedGaussianSampler, SharedStateContinuousSampler
Modified ziggurat method for sampling from a Gaussian distribution with mean 0 and standard deviation 1.Note: The algorithm is a modification of the
Marsaglia and Tsang "Ziggurat" method
. The modification improves performance of the rejection method used to generate samples at the edge of the ziggurat.- See Also:
NormalizedGaussianSampler
,GaussianSampler
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.rng.sampling.distribution.ZigguratSampler
ZigguratSampler.Exponential, ZigguratSampler.NormalizedGaussian
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ZigguratSampler.NormalizedGaussian
of(UniformRandomProvider rng)
Create a new normalised Gaussian sampler.double
sample()
Creates a sample.String
toString()
ZigguratSampler.NormalizedGaussian
withUniformRandomProvider(UniformRandomProvider rng)
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.
-
-
-
Method Detail
-
sample
public double sample()
Creates a sample.- Specified by:
sample
in interfaceContinuousSampler
- Returns:
- a sample.
-
withUniformRandomProvider
public ZigguratSampler.NormalizedGaussian withUniformRandomProvider(UniformRandomProvider rng)
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.- Specified by:
withUniformRandomProvider
in interfaceSharedStateSampler<SharedStateContinuousSampler>
- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
of
public static ZigguratSampler.NormalizedGaussian of(UniformRandomProvider rng)
Create a new normalised Gaussian sampler.- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
-