Package org.apache.spark.util.random
Class BernoulliSampler<T>
Object
org.apache.spark.util.random.BernoulliSampler<T>
- Type Parameters:
- T- item type
- All Implemented Interfaces:
- Serializable,- Cloneable,- Pseudorandom,- RandomSampler<T,- T> 
:: DeveloperApi ::
 A sampler based on Bernoulli trials.
 
param: fraction the sampling fraction, aka Bernoulli sampling probability
- See Also:
- 
Constructor Details- 
BernoulliSampler
 
- 
- 
Method Details- 
cloneDescription copied from interface:RandomSamplerreturn a copy of the RandomSampler object- Specified by:
- clonein interface- RandomSampler<T,- T> 
 
- 
samplepublic int sample()Description copied from interface:RandomSamplerWhether 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:
- samplein interface- RandomSampler<T,- T> 
- Returns:
- (undocumented)
 
- 
setSeedpublic void setSeed(long seed) Description copied from interface:PseudorandomSet random seed.- Specified by:
- setSeedin interface- Pseudorandom
 
 
-