Class AliasSamplerDoubleInt
java.lang.Object
io.nosqlbench.virtdata.library.basics.core.stathelpers.AliasSamplerDoubleInt
- All Implemented Interfaces:
java.util.function.DoubleToIntFunction
public class AliasSamplerDoubleInt
extends java.lang.Object
implements java.util.function.DoubleToIntFunction
Uses the alias sampling method to encode and sample from discrete probabilities,
even over larger sets of data. This form requires a unit interval sample value
between 0.0 and 1.0. Assuming the maximal amount of memory is used for distinct
outcomes N, a memory buffer of N*16 bytes is required for this implementation,
requiring 32MB of memory for 1M entries.
This sampler should be shared between threads, and will be by default, in order
to avoid many instances of a 32MB buffer on heap.
-
Field Summary
Fields Modifier and Type Field Description static intRECORD_LEN -
Constructor Summary
Constructors Constructor Description AliasSamplerDoubleInt(java.util.List<EvProbD> events) -
Method Summary
Modifier and Type Method Description intapplyAsInt(double value)
-
Field Details
-
RECORD_LEN
public static int RECORD_LEN
-
-
Constructor Details
-
Method Details
-
applyAsInt
public int applyAsInt(double value)- Specified by:
applyAsIntin interfacejava.util.function.DoubleToIntFunction
-