Class LogNormalSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.LogNormalSampler
- All Implemented Interfaces:
ContinuousSampler, SharedStateContinuousSampler, SharedStateSampler<SharedStateContinuousSampler>
Sampling from a log-normal distribution.
- Since:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final NormalizedGaussianSamplerGaussian sampling.private final doubleMean of the natural logarithm of the distribution values.private final doubleStandard deviation of the natural logarithm of the distribution values. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateLogNormalSampler(double mu, double sigma, NormalizedGaussianSampler gaussian) LogNormalSampler(NormalizedGaussianSampler gaussian, double mu, double sigma) Create an instance.privateLogNormalSampler(UniformRandomProvider rng, LogNormalSampler source) -
Method Summary
Modifier and TypeMethodDescriptionstatic SharedStateContinuousSamplerof(NormalizedGaussianSampler gaussian, double mu, double sigma) Create a new log-normal distribution 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
-
Field Details
-
mu
private final double muMean of the natural logarithm of the distribution values. -
sigma
private final double sigmaStandard deviation of the natural logarithm of the distribution values. -
gaussian
Gaussian sampling.
-
-
Constructor Details
-
LogNormalSampler
Create an instance.- 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:
IllegalArgumentException- ifsigma <= 0.
-
LogNormalSampler
- Parameters:
mu- Mean of the natural logarithm of the distribution values.sigma- Standard deviation of the natural logarithm of the distribution values.gaussian- N(0,1) generator.
-
LogNormalSampler
- Parameters:
rng- Generator of uniformly distributed random numbers.source- Source to copy.
-
-
Method Details
-
sample
public double 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.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 mu, double sigma) 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.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:
IllegalArgumentException- ifsigma <= 0.- Since:
- 1.3
- See Also:
-