Class MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int16DiscreteSampler
- java.lang.Object
-
- org.apache.commons.rng.sampling.distribution.MarsagliaTsangWangDiscreteSampler.AbstractMarsagliaTsangWangDiscreteSampler
-
- org.apache.commons.rng.sampling.distribution.MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int16DiscreteSampler
-
- All Implemented Interfaces:
DiscreteSampler
,SharedStateDiscreteSampler
,SharedStateSampler<SharedStateDiscreteSampler>
- Enclosing class:
- MarsagliaTsangWangDiscreteSampler
private static final class MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int16DiscreteSampler 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 16-bit backing storage.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
MASK
The mask to convert abyte
to an unsigned 16-bit integer.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 short[]
table1
Look-up table table1.private short[]
table2
Look-up table table2.private short[]
table3
Look-up table table3.private short[]
table4
Look-up table table4.private short[]
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)
MarsagliaTsangWangBase64Int16DiscreteSampler(UniformRandomProvider rng, java.lang.String distributionName, int[] prob, int offset)
private
MarsagliaTsangWangBase64Int16DiscreteSampler(UniformRandomProvider rng, MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int16DiscreteSampler source)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static int
fill(short[] table, int from, int to, short 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
-
MASK
private static final int MASK
The mask to convert abyte
to an unsigned 16-bit integer.- See Also:
- Constant Field Values
-
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 short[] table1
Look-up table table1.
-
table2
private final short[] table2
Look-up table table2.
-
table3
private final short[] table3
Look-up table table3.
-
table4
private final short[] table4
Look-up table table4.
-
table5
private final short[] table5
Look-up table table5.
-
-
Constructor Detail
-
MarsagliaTsangWangBase64Int16DiscreteSampler
MarsagliaTsangWangBase64Int16DiscreteSampler(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).
-
MarsagliaTsangWangBase64Int16DiscreteSampler
private MarsagliaTsangWangBase64Int16DiscreteSampler(UniformRandomProvider rng, MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int16DiscreteSampler source)
- Parameters:
rng
- Generator of uniformly distributed random numbers.source
- Source to copy.
-
-
Method Detail
-
fill
private static int fill(short[] table, int from, int to, short 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
-
-