Class ReservoirSampler<T>

  • All Implemented Interfaces:
    Sampler<T>

    public abstract class ReservoirSampler<T>
    extends java.lang.Object
    implements Sampler<T>
    Utility to do reservoir sampling with competitions over shared space.
    • Constructor Summary

      Constructors 
      Constructor Description
      ReservoirSampler​(int sampleSize)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract T letCompete​(T candidate1, T candidate2, java.util.Random random)  
      java.util.List<T> sample​(java.util.Collection<T> set, Battle<T> battle, double selectionProbability)
      Create a sample from a given Collection.
      • Methods inherited from class java.lang.Object

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

      • ReservoirSampler

        public ReservoirSampler​(int sampleSize)
    • Method Detail

      • sample

        public java.util.List<T> sample​(java.util.Collection<T> set,
                                        Battle<T> battle,
                                        double selectionProbability)
        Description copied from interface: Sampler
        Create a sample from a given Collection.
        Specified by:
        sample in interface Sampler<T>
        Parameters:
        set - the set of elements to be sampled from
        battle - lets two elements compete
        Returns:
        the sample; may contain nulls dependent on the implementation
      • letCompete

        protected abstract T letCompete​(T candidate1,
                                        T candidate2,
                                        java.util.Random random)