Class ZigguratNormalizedGaussianSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.ZigguratNormalizedGaussianSampler
- All Implemented Interfaces:
ContinuousSampler, NormalizedGaussianSampler, SharedStateContinuousSampler, SharedStateSampler<SharedStateContinuousSampler>
public class ZigguratNormalizedGaussianSampler
extends Object
implements NormalizedGaussianSampler, SharedStateContinuousSampler
Marsaglia and Tsang "Ziggurat" method for sampling from a Gaussian
distribution with mean 0 and standard deviation 1.
The algorithm is explained in this paper and this implementation has been adapted from the C code provided therein.
Sampling uses:
- Since:
- 1.1
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic <S extends NormalizedGaussianSampler & SharedStateContinuousSampler>
Sof(UniformRandomProvider rng) Create a new normalised Gaussian sampler.doublesample()Creates adoublesample.toString()Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ContinuousSampler
samples, samples
-
Constructor Details
-
ZigguratNormalizedGaussianSampler
Create an instance.- Parameters:
rng- Generator of uniformly distributed random numbers.
-
-
Method Details
-
sample
Creates adoublesample.- Specified by:
samplein interfaceContinuousSampler- Returns:
- a sample.
-
toString
-
withUniformRandomProvider
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:
withUniformRandomProviderin interfaceSharedStateSampler<SharedStateContinuousSampler>- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
- Since:
- 1.3
-
of
public static <S extends NormalizedGaussianSampler & SharedStateContinuousSampler> S of(UniformRandomProvider rng) Create a new normalised Gaussian sampler.- Type Parameters:
S- Sampler type.- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
- Since:
- 1.3
-