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 final class GeometricSampler.GeometricExponentialSampler
extends Object
implements SharedStateDiscreteSampler
Sample from the geometric distribution by using a related exponential distribution.
- Since:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SharedStateContinuousSamplerThe related exponential sampler for the geometric distribution.private final UniformRandomProviderUnderlying source of randomness. -
Constructor Summary
ConstructorsConstructorDescriptionGeometricExponentialSampler(UniformRandomProvider rng, double probabilityOfSuccess) GeometricExponentialSampler(UniformRandomProvider rng, GeometricSampler.GeometricExponentialSampler source) -
Method Summary
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface 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:DiscreteSamplerCreates anintsample.- Specified by:
samplein interfaceDiscreteSampler- Returns:
- a sample.
-
toString
-
withUniformRandomProvider
Description copied from interface:SharedStateSamplerCreate 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<SharedStateDiscreteSampler>- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-