Class AliasElementSampler<T>

java.lang.Object
io.nosqlbench.virtdata.library.basics.core.stathelpers.AliasElementSampler<T>
All Implemented Interfaces:
java.util.function.DoubleFunction<T>

public class AliasElementSampler<T>
extends java.lang.Object
implements java.util.function.DoubleFunction<T>
Uses the alias sampling method to encode and sample from discrete probabilities, even over large 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.
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static interface  AliasElementSampler.Weighted  
  • Constructor Summary

    Constructors 
    Constructor Description
    AliasElementSampler​(java.util.List<ElemProbD<T>> events)  
  • Method Summary

    Modifier and Type Method Description
    T apply​(double value)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • apply

      public T apply​(double value)
      Specified by:
      apply in interface java.util.function.DoubleFunction<T>