T - type of sampled objectspublic class WeightedSampling<T> extends Object
| Constructor and Description |
|---|
WeightedSampling(Stream<T> elems,
ToDoubleFunction<T> value,
boolean withReplacement)
Constructor
|
WeightedSampling(Stream<T> elems,
ToDoubleFunction<T> value,
boolean withReplacement,
long seed)
Constructor.
|
WeightedSampling(Stream<T> elems,
ToDoubleFunction<T> value,
boolean withReplacement,
Random rnd)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
T |
sample()
Sample an element.
|
Stream<T> |
sample(int k)
Sample k elements.
|
public WeightedSampling(Stream<T> elems, ToDoubleFunction<T> value, boolean withReplacement)
elems - stream of element to sample fromvalue - sampling weight functionwithReplacement - if true selection with replacement, without otherwisepublic WeightedSampling(Stream<T> elems, ToDoubleFunction<T> value, boolean withReplacement, long seed)
elems - stream of element to sample fromvalue - sampling weight functionwithReplacement - if true selection with replacement, without otherwiseseed - seed to Random constructorpublic WeightedSampling(Stream<T> elems, ToDoubleFunction<T> value, boolean withReplacement, Random rnd)
elems - stream of element to sample fromvalue - sampling weight functionwithReplacement - if true selection with replacement, without otherwisernd - randomCopyright © 2016. All rights reserved.