Class AhrensDieterExponentialSampler
- java.lang.Object
-
- org.apache.commons.rng.sampling.distribution.SamplerBase
-
- org.apache.commons.rng.sampling.distribution.AhrensDieterExponentialSampler
-
- All Implemented Interfaces:
ContinuousSampler
,SharedStateContinuousSampler
,SharedStateSampler<SharedStateContinuousSampler>
public class AhrensDieterExponentialSampler extends SamplerBase implements SharedStateContinuousSampler
Sampling from an exponential distribution.Sampling uses:
- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description AhrensDieterExponentialSampler(UniformRandomProvider rng, double mean)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SharedStateContinuousSampler
of(UniformRandomProvider rng, double mean)
Create a new exponential distribution sampler.double
sample()
Creates a sample.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 org.apache.commons.rng.sampling.distribution.SamplerBase
nextDouble, nextInt, nextInt, nextLong
-
-
-
-
Constructor Detail
-
AhrensDieterExponentialSampler
public AhrensDieterExponentialSampler(UniformRandomProvider rng, double mean)
- Parameters:
rng
- Generator of uniformly distributed random numbers.mean
- Mean of this distribution.- Throws:
IllegalArgumentException
- ifmean <= 0
-
-
Method Detail
-
sample
public double sample()
Creates a sample.- Specified by:
sample
in interfaceContinuousSampler
- Returns:
- a sample.
-
toString
public String toString()
- Overrides:
toString
in classSamplerBase
-
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.- Specified by:
withUniformRandomProvider
in interfaceSharedStateSampler<SharedStateContinuousSampler>
- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
- Since:
- 1.3
-
of
public static SharedStateContinuousSampler of(UniformRandomProvider rng, double mean)
Create a new exponential distribution sampler.- Parameters:
rng
- Generator of uniformly distributed random numbers.mean
- Mean of the distribution.- Returns:
- the sampler
- Throws:
IllegalArgumentException
- ifmean <= 0
- Since:
- 1.3
-
-