Class LogNormalSampler
- java.lang.Object
-
- org.apache.commons.rng.sampling.distribution.LogNormalSampler
-
- All Implemented Interfaces:
ContinuousSampler,SharedStateContinuousSampler,SharedStateSampler<SharedStateContinuousSampler>
public class LogNormalSampler extends Object implements SharedStateContinuousSampler
Sampling from a log-normal distribution.- Since:
- 1.1
-
-
Constructor Summary
Constructors Constructor Description LogNormalSampler(NormalizedGaussianSampler gaussian, double scale, double shape)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SharedStateContinuousSamplerof(NormalizedGaussianSampler gaussian, double scale, double shape)Create a new log-normal distribution sampler.doublesample()Creates a sample.StringtoString()SharedStateContinuousSamplerwithUniformRandomProvider(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.
-
-
-
Constructor Detail
-
LogNormalSampler
public LogNormalSampler(NormalizedGaussianSampler gaussian, double scale, double shape)
- Parameters:
gaussian- N(0,1) generator.scale- Scale of the log-normal distribution.shape- Shape of the log-normal distribution.- Throws:
IllegalArgumentException- ifscale < 0orshape <= 0.
-
-
Method Detail
-
sample
public double sample()
Creates a sample.- Specified by:
samplein interfaceContinuousSampler- Returns:
- a sample.
-
withUniformRandomProvider
public SharedStateContinuousSampler 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.Note: This function is available if the underlying
NormalizedGaussianSampleris aSharedStateSampler. Otherwise a run-time exception is thrown.- Specified by:
withUniformRandomProviderin interfaceSharedStateSampler<SharedStateContinuousSampler>- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
- Throws:
UnsupportedOperationException- if the underlying sampler is not aSharedStateSampleror does not return aNormalizedGaussianSamplerwhen sharing state.- Since:
- 1.3
-
of
public static SharedStateContinuousSampler of(NormalizedGaussianSampler gaussian, double scale, double shape)
Create a new log-normal distribution sampler.Note: The shared-state functionality is available if the
NormalizedGaussianSampleris aSharedStateSampler. Otherwise a run-time exception will be thrown when the sampler is used to share state.- Parameters:
gaussian- N(0,1) generator.scale- Scale of the log-normal distribution.shape- Shape of the log-normal distribution.- Returns:
- the sampler
- Throws:
IllegalArgumentException- ifscale < 0orshape <= 0.- Since:
- 1.3
- See Also:
withUniformRandomProvider(UniformRandomProvider)
-
-