RandomSelectors

public class RandomSelectors

Contains ResultSelector's to be used with a java.util.stream.Stream as a collection operation.

Functions

scaledSd
Link copied to clipboard
static ResultSelector<TscaledSd<T>(double sdPercent)
Creates a result selector that randomly selects an element where the element index is selected with the formula:
var resultIndex = randomSd(0, list.size() - 1, 0, sdPercent * list.size())
where randomSd generates a random number from a normal distribution with the parameters min/max/mean/sd
static ResultSelector<TscaledSd<T>(double meanPercent, double sdPercent)
Creates a result selector that randomly selects an element where the element index is selected with the formula:
var resultIndex = randomSd(0, list.size() - 1, meanPercent * (list.size() - 1), sdPercent * list.size())
where randomSd generates a random number from a normal distribution with the parameters min/max/mean/sd
uniform
Link copied to clipboard
static ResultSelector<Tuniform<T>()
Creates a result selector that randomly selects an element using a uniform distribution
weighted
Link copied to clipboard
static ResultSelector<Tweighted<T>(ToDoubleFunction<T> weightExtractor)
Creates a result selector that randomly selects an element where each element is given a specific weight based on the weight extractor function.