Class LevySampler
- java.lang.Object
-
- org.apache.commons.rng.sampling.distribution.LevySampler
-
- All Implemented Interfaces:
ContinuousSampler,SharedStateContinuousSampler,SharedStateSampler<SharedStateContinuousSampler>
public final class LevySampler extends java.lang.Object implements SharedStateContinuousSampler
Sampling from a Lévy distribution.- Since:
- 1.4
- See Also:
- Lévy distribution
-
-
Field Summary
Fields Modifier and Type Field Description private NormalizedGaussianSamplergaussianGaussian sampler.private doublelocationLocation.private UniformRandomProviderrngRNG (used for the toString() method).private doublescaleScale.
-
Constructor Summary
Constructors Modifier Constructor Description privateLevySampler(UniformRandomProvider rng, double location, double scale)privateLevySampler(UniformRandomProvider rng, LevySampler source)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LevySamplerof(UniformRandomProvider rng, double location, double scale)Create a new Lévy distribution sampler.doublesample()Creates adoublesample.java.lang.StringtoString()LevySamplerwithUniformRandomProvider(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
-
gaussian
private final NormalizedGaussianSampler gaussian
Gaussian sampler.
-
location
private final double location
Location.
-
scale
private final double scale
Scale.
-
rng
private final UniformRandomProvider rng
RNG (used for the toString() method).
-
-
Constructor Detail
-
LevySampler
private LevySampler(UniformRandomProvider rng, double location, double scale)
- Parameters:
rng- Generator of uniformly distributed random numbers.location- Location of the Lévy distribution.scale- Scale of the Lévy distribution.
-
LevySampler
private LevySampler(UniformRandomProvider rng, LevySampler source)
- Parameters:
rng- Generator of uniformly distributed random numbers.source- Source to copy.
-
-
Method Detail
-
sample
public double sample()
Creates adoublesample.- Specified by:
samplein interfaceContinuousSampler- Returns:
- a sample.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
withUniformRandomProvider
public LevySampler 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:
withUniformRandomProviderin interfaceSharedStateSampler<SharedStateContinuousSampler>- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
of
public static LevySampler of(UniformRandomProvider rng, double location, double scale)
Create a new Lévy distribution sampler.- Parameters:
rng- Generator of uniformly distributed random numbers.location- Location of the Lévy distribution.scale- Scale of the Lévy distribution.- Returns:
- the sampler
- Throws:
java.lang.IllegalArgumentException- ifscale <= 0
-
-