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.
-
-
Field Summary
Fields Modifier and Type Field Description private int
t1
Limit for look-up table 1.private int
t2
Limit for look-up table 2.private int
t3
Limit for look-up table 3.private int
t4
Limit for look-up table 4.private int[]
table1
Look-up table table1.private int[]
table2
Look-up table table2.private int[]
table3
Look-up table table3.private int[]
table4
Look-up table table4.private int[]
table5
Look-up table table5.-
Fields inherited from class org.apache.commons.rng.sampling.distribution.MarsagliaTsangWangDiscreteSampler.AbstractMarsagliaTsangWangDiscreteSampler
rng
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
MarsagliaTsangWangBase64Int32DiscreteSampler(UniformRandomProvider rng, java.lang.String distributionName, int[] prob, int offset)
private
MarsagliaTsangWangBase64Int32DiscreteSampler(UniformRandomProvider rng, MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int32DiscreteSampler source)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static int
fill(int[] table, int from, int to, int value)
Fill the table with the value.int
sample()
Creates anint
sample.SharedStateDiscreteSampler
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.MarsagliaTsangWangDiscreteSampler.AbstractMarsagliaTsangWangDiscreteSampler
toString
-
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
-
t1
private final int t1
Limit for look-up table 1.
-
t2
private final int t2
Limit for look-up table 2.
-
t3
private final int t3
Limit for look-up table 3.
-
t4
private final int t4
Limit for look-up table 4.
-
table1
private final int[] table1
Look-up table table1.
-
table2
private final int[] table2
Look-up table table2.
-
table3
private final int[] table3
Look-up table table3.
-
table4
private final int[] table4
Look-up table table4.
-
table5
private final int[] table5
Look-up table table5.
-
-
Constructor Detail
-
MarsagliaTsangWangBase64Int32DiscreteSampler
MarsagliaTsangWangBase64Int32DiscreteSampler(UniformRandomProvider rng, java.lang.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 Detail
-
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:DiscreteSampler
Creates anint
sample.- Returns:
- a sample.
-
withUniformRandomProvider
public SharedStateDiscreteSampler withUniformRandomProvider(UniformRandomProvider rng)
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.- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
-