Class GeometricSampler.GeometricExponentialSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.GeometricSampler.GeometricExponentialSampler
- All Implemented Interfaces:
DiscreteSampler
,SharedStateDiscreteSampler
,SharedStateSampler<SharedStateDiscreteSampler>
- Enclosing class:
GeometricSampler
private static class GeometricSampler.GeometricExponentialSampler
extends Object
implements SharedStateDiscreteSampler
Sample from the geometric distribution by using a related exponential distribution.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SharedStateContinuousSampler
The related exponential sampler for the geometric distribution.private final UniformRandomProvider
Underlying source of randomness. -
Constructor Summary
ConstructorsConstructorDescriptionGeometricExponentialSampler
(UniformRandomProvider rng, double probabilityOfSuccess) GeometricExponentialSampler
(UniformRandomProvider rng, GeometricSampler.GeometricExponentialSampler source) -
Method Summary
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.DiscreteSampler
samples, samples
-
Field Details
-
rng
Underlying source of randomness. Used only for thetoString()
method. -
exponentialSampler
The related exponential sampler for the geometric distribution.
-
-
Constructor Details
-
GeometricExponentialSampler
GeometricExponentialSampler(UniformRandomProvider rng, double probabilityOfSuccess) - Parameters:
rng
- Generator of uniformly distributed random numbersprobabilityOfSuccess
- The probability of success (must be in the range[0 < probabilityOfSuccess < 1]
)
-
GeometricExponentialSampler
GeometricExponentialSampler(UniformRandomProvider rng, GeometricSampler.GeometricExponentialSampler source) - Parameters:
rng
- Generator of uniformly distributed random numberssource
- Source to copy.
-
-
Method Details
-
sample
public int sample()Description copied from interface:DiscreteSampler
Creates anint
sample.- Specified by:
sample
in interfaceDiscreteSampler
- Returns:
- a sample.
-
toString
-
withUniformRandomProvider
Description copied from interface:SharedStateSampler
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<SharedStateDiscreteSampler>
- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-