Class MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int32DiscreteSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.MarsagliaTsangWangDiscreteSampler.AbstractMarsagliaTsangWangDiscreteSampler
org.apache.commons.rng.sampling.distribution.MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int32DiscreteSampler
- All Implemented Interfaces:
DiscreteSampler, SharedStateDiscreteSampler, SharedStateSampler<SharedStateDiscreteSampler>
- Enclosing class:
MarsagliaTsangWangDiscreteSampler
private static final class MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int32DiscreteSampler
extends MarsagliaTsangWangDiscreteSampler.AbstractMarsagliaTsangWangDiscreteSampler
An implementation for the sample algorithm based on the decomposition of the
index in the range
[0,2^30) into 5 base-64 digits with 32-bit backing storage.- Since:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intLimit for look-up table 1.private final intLimit for look-up table 2.private final intLimit for look-up table 3.private final intLimit for look-up table 4.private final int[]Look-up table table1.private final int[]Look-up table table2.private final int[]Look-up table table3.private final int[]Look-up table table4.private final int[]Look-up table table5.Fields inherited from class MarsagliaTsangWangDiscreteSampler.AbstractMarsagliaTsangWangDiscreteSampler
rng -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)MarsagliaTsangWangBase64Int32DiscreteSampler(UniformRandomProvider rng, String distributionName, int[] prob, int offset) privateMarsagliaTsangWangBase64Int32DiscreteSampler(UniformRandomProvider rng, MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int32DiscreteSampler source) -
Method Summary
Modifier and TypeMethodDescriptionprivate static intfill(int[] table, int from, int to, int value) Fill the table with the value.intsample()Creates anintsample.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 MarsagliaTsangWangDiscreteSampler.AbstractMarsagliaTsangWangDiscreteSampler
toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface DiscreteSampler
samples, samples
-
Field Details
-
t1
private final int t1Limit for look-up table 1. -
t2
private final int t2Limit for look-up table 2. -
t3
private final int t3Limit for look-up table 3. -
t4
private final int t4Limit for look-up table 4. -
table1
private final int[] table1Look-up table table1. -
table2
private final int[] table2Look-up table table2. -
table3
private final int[] table3Look-up table table3. -
table4
private final int[] table4Look-up table table4. -
table5
private final int[] table5Look-up table table5.
-
-
Constructor Details
-
MarsagliaTsangWangBase64Int32DiscreteSampler
MarsagliaTsangWangBase64Int32DiscreteSampler(UniformRandomProvider rng, String distributionName, int[] prob, int offset) - Parameters:
rng- Generator of uniformly distributed random numbers.distributionName- Distribution name.prob- The probabilities.offset- The offset (must be positive).
-
MarsagliaTsangWangBase64Int32DiscreteSampler
private MarsagliaTsangWangBase64Int32DiscreteSampler(UniformRandomProvider rng, MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int32DiscreteSampler source) - Parameters:
rng- Generator of uniformly distributed random numbers.source- Source to copy.
-
-
Method Details
-
fill
private static int fill(int[] table, int from, int to, int value) Fill the table with the value.- Parameters:
table- Table.from- Lower bound index (inclusive)to- Upper bound index (exclusive)value- Value.- Returns:
- the upper bound index
-
sample
public int sample()Description copied from interface:DiscreteSamplerCreates anintsample.- Returns:
- a sample.
-
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.- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-