RandomSelectors

open class RandomSelectors

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

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open fun <T> scaledSd(sdPercent: Double): ResultSelector<T>
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
open fun <T> scaledSd(meanPercent: Double, sdPercent: Double): ResultSelector<T>
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
Link copied to clipboard
open fun <T> uniform(): ResultSelector<T>
Creates a result selector that randomly selects an element using a uniform distribution
Link copied to clipboard
open fun <T> weighted(weightExtractor: ToDoubleFunction<T>): ResultSelector<T>
Creates a result selector that randomly selects an element where each element is given a specific weight based on the weight extractor function.