Class PoissonSampler<T>

Object
org.apache.spark.util.random.PoissonSampler<T>
Type Parameters:
T - item type
All Implemented Interfaces:
Serializable, Cloneable, Pseudorandom, RandomSampler<T,T>

public class PoissonSampler<T> extends Object implements RandomSampler<T,T>
:: DeveloperApi :: A sampler for sampling with replacement, based on values drawn from Poisson distribution.

param: fraction the sampling fraction (with replacement) param: useGapSamplingIfPossible if true, use gap sampling when sampling ratio is low.

See Also:
  • Constructor Details

    • PoissonSampler

      public PoissonSampler(double fraction, boolean useGapSamplingIfPossible)
    • PoissonSampler

      public PoissonSampler(double fraction)
  • Method Details

    • clone

      public PoissonSampler<T> clone()
      Description copied from interface: RandomSampler
      return a copy of the RandomSampler object
      Specified by:
      clone in interface RandomSampler<T,T>
    • sample

      public int sample()
      Description copied from interface: RandomSampler
      Whether to sample the next item or not. Return how many times the next item will be sampled. Return 0 if it is not sampled.
      Specified by:
      sample in interface RandomSampler<T,T>
      Returns:
      (undocumented)
    • sample

      public scala.collection.Iterator<T> sample(scala.collection.Iterator<T> items)
      Description copied from interface: RandomSampler
      take a random sample
      Specified by:
      sample in interface RandomSampler<T,T>
    • setSeed

      public void setSeed(long seed)
      Description copied from interface: Pseudorandom
      Set random seed.
      Specified by:
      setSeed in interface Pseudorandom