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 java.lang.Object implements SharedStateDiscreteSampler
Sample from the geometric distribution by using a related exponential distribution.
-
-
Field Summary
Fields Modifier and Type Field Description private SharedStateContinuousSamplerexponentialSamplerThe related exponential sampler for the geometric distribution.private UniformRandomProviderrngUnderlying source of randomness.
-
Constructor Summary
Constructors Constructor Description GeometricExponentialSampler(UniformRandomProvider rng, double probabilityOfSuccess)GeometricExponentialSampler(UniformRandomProvider rng, GeometricSampler.GeometricExponentialSampler source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intsample()Creates anintsample.java.lang.StringtoString()SharedStateDiscreteSamplerwithUniformRandomProvider(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.DiscreteSampler
samples, samples
-
-
-
-
Field Detail
-
rng
private final UniformRandomProvider rng
Underlying source of randomness. Used only for thetoString()method.
-
exponentialSampler
private final SharedStateContinuousSampler exponentialSampler
The related exponential sampler for the geometric distribution.
-
-
Constructor Detail
-
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 Detail
-
sample
public int sample()
Description copied from interface:DiscreteSamplerCreates anintsample.- Specified by:
samplein interfaceDiscreteSampler- Returns:
- a sample.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
withUniformRandomProvider
public SharedStateDiscreteSampler withUniformRandomProvider(UniformRandomProvider rng)
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
-
-