Package org.apache.spark.util.random
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> scala.Cloneable
,scala.Serializable
:: 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 Summary
ConstructorDescriptionPoissonSampler
(double fraction) PoissonSampler
(double fraction, boolean useGapSamplingIfPossible) -
Method Summary
-
Constructor Details
-
PoissonSampler
public PoissonSampler(double fraction, boolean useGapSamplingIfPossible) -
PoissonSampler
public PoissonSampler(double fraction)
-
-
Method Details
-
clone
Description copied from interface:RandomSampler
return a copy of the RandomSampler object- Specified by:
clone
in interfaceRandomSampler<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 interfaceRandomSampler<T,
T> - Returns:
- (undocumented)
-
sample
Description copied from interface:RandomSampler
take a random sample- Specified by:
sample
in interfaceRandomSampler<T,
T>
-
setSeed
public void setSeed(long seed) Description copied from interface:Pseudorandom
Set random seed.- Specified by:
setSeed
in interfacePseudorandom
-