Class LogNormalSampler
- java.lang.Object
-
- org.apache.commons.rng.sampling.distribution.LogNormalSampler
-
- All Implemented Interfaces:
ContinuousSampler
,SharedStateContinuousSampler
,SharedStateSampler<SharedStateContinuousSampler>
public class LogNormalSampler extends java.lang.Object implements SharedStateContinuousSampler
Sampling from a log-normal distribution.- Since:
- 1.1
-
-
Field Summary
Fields Modifier and Type Field Description private NormalizedGaussianSampler
gaussian
Gaussian sampling.private double
mu
Mean of the natural logarithm of the distribution values.private double
sigma
Standard deviation of the natural logarithm of the distribution values.
-
Constructor Summary
Constructors Modifier Constructor Description LogNormalSampler(NormalizedGaussianSampler gaussian, double mu, double sigma)
private
LogNormalSampler(UniformRandomProvider rng, LogNormalSampler source)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SharedStateContinuousSampler
of(NormalizedGaussianSampler gaussian, double mu, double sigma)
Create a new log-normal distribution sampler.double
sample()
Creates adouble
sample.java.lang.String
toString()
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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.rng.sampling.distribution.ContinuousSampler
samples, samples
-
-
-
-
Field Detail
-
mu
private final double mu
Mean of the natural logarithm of the distribution values.
-
sigma
private final double sigma
Standard deviation of the natural logarithm of the distribution values.
-
gaussian
private final NormalizedGaussianSampler gaussian
Gaussian sampling.
-
-
Constructor Detail
-
LogNormalSampler
public LogNormalSampler(NormalizedGaussianSampler gaussian, double mu, double sigma)
- Parameters:
gaussian
- N(0,1) generator.mu
- Mean of the natural logarithm of the distribution values.sigma
- Standard deviation of the natural logarithm of the distribution values.- Throws:
java.lang.IllegalArgumentException
- ifsigma <= 0
.
-
LogNormalSampler
private LogNormalSampler(UniformRandomProvider rng, LogNormalSampler source)
- Parameters:
rng
- Generator of uniformly distributed random numbers.source
- Source to copy.
-
-
Method Detail
-
sample
public double sample()
Creates adouble
sample.- Specified by:
sample
in interfaceContinuousSampler
- Returns:
- a sample.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
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
NormalizedGaussianSampler
is aSharedStateSampler
. Otherwise a run-time exception is thrown.- Specified by:
withUniformRandomProvider
in interfaceSharedStateSampler<SharedStateContinuousSampler>
- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
- Throws:
java.lang.UnsupportedOperationException
- if the underlying sampler is not aSharedStateSampler
or does not return aNormalizedGaussianSampler
when sharing state.- Since:
- 1.3
-
of
public static SharedStateContinuousSampler of(NormalizedGaussianSampler gaussian, double mu, double sigma)
Create a new log-normal distribution sampler.Note: The shared-state functionality is available if the
NormalizedGaussianSampler
is aSharedStateSampler
. Otherwise a run-time exception will be thrown when the sampler is used to share state.- Parameters:
gaussian
- N(0,1) generator.mu
- Mean of the natural logarithm of the distribution values.sigma
- Standard deviation of the natural logarithm of the distribution values.- Returns:
- the sampler
- Throws:
java.lang.IllegalArgumentException
- ifsigma <= 0
.- Since:
- 1.3
- See Also:
withUniformRandomProvider(UniformRandomProvider)
-
-