Package-level declarations

Types

Link copied to clipboard
data class Bin<T>(val range: ClosedRange<Double>, val items: List<T>)

A histogram bin containing the items that fall within a value range.

Link copied to clipboard
data class BootstrapCIResult(val percentile: ConfidenceInterval, val basic: ConfidenceInterval, val bca: ConfidenceInterval, val observedStatistic: Double, val nResamples: Int, val confidenceLevel: Double)

The result of a bootstrap confidence interval computation, containing three CI methods.

Link copied to clipboard
data class FrequencyBin(val range: ClosedRange<Double>, val count: Int, val relativeFrequency: Double, val cumulativeFrequency: Double)

A histogram bin with frequency statistics but without the original items.

Link copied to clipboard

Controls how tied (equal) values are assigned ranks.

Link copied to clipboard
class WeightedCoin(val probability: Double, random: Random = Random)

A biased coin that lands heads (true) with the given probability.

Link copied to clipboard
class WeightedDice<T>(weights: Map<T, Double>, random: Random = Random)

A weighted die that produces outcomes with probabilities proportional to their weights.

Functions

Link copied to clipboard
fun DoubleArray.bin(binSize: Double): List<Bin<Double>>
fun Iterable<Double>.bin(binSize: Double): List<Bin<Double>>

Groups the values into equal-width bins of the given binSize.

fun DoubleArray.bin(binCount: Int): List<Bin<Double>>
fun Iterable<Double>.bin(binCount: Int): List<Bin<Double>>

Groups the values into a fixed number of equal-width bins.

Link copied to clipboard
fun <T> Iterable<T>.binByDouble(valueSelector: (T) -> Double, binCount: Int): List<Bin<T>>

Groups items into a fixed number of equal-width bins based on a numeric value extracted by valueSelector.

fun <T> Iterable<T>.binByDouble(valueSelector: (T) -> Double, binSize: Double, rangeStart: Double? = null): List<Bin<T>>

Groups items into equal-width bins based on a numeric value extracted by valueSelector.

Link copied to clipboard
fun bootstrapCI(data: DoubleArray, nResamples: Int, confidenceLevel: Double = 0.95, random: Random = Random, statistic: (DoubleArray) -> Double): BootstrapCIResult

Computes bootstrap confidence intervals for a statistic using three methods: percentile, basic (pivotal), and BCa (bias-corrected and accelerated).

fun <T> bootstrapCI(data: List<T>, nResamples: Int, confidenceLevel: Double = 0.95, random: Random = Random, statistic: (List<T>) -> Double): BootstrapCIResult

Computes bootstrap confidence intervals for a statistic on a list of arbitrary elements, using three methods: percentile, basic (pivotal), and BCa (bias-corrected and accelerated).

Link copied to clipboard
fun <T> Iterable<T>.bootstrapSample(n: Int, random: Random = Random): List<T>
fun <T> List<T>.bootstrapSample(n: Int, random: Random = Random): List<T>

Draws a bootstrap sample of n elements with replacement.

Link copied to clipboard

Builds a frequency table by dividing the values into equal-width bins of the given size.

Builds a frequency table by dividing the values into a fixed number of equal-width bins.

Link copied to clipboard

Scales each element to the range 0, 1 using min-max normalization.

Scales each element to the range [newMin, newMax] using min-max normalization.

Link copied to clipboard

Computes the percentile rank of each element, indicating what percentage of values fall at or below it.

Link copied to clipboard
fun <T> Iterable<T>.randomSample(n: Int, random: Random = Random): List<T>

Draws a random sample of n elements without replacement.

Link copied to clipboard
fun DoubleArray.rank(tieMethod: TieMethod = TieMethod.AVERAGE): DoubleArray
fun Iterable<Double>.rank(tieMethod: TieMethod = TieMethod.AVERAGE): List<Double>

Computes ranks for each element based on its relative position when sorted.

Link copied to clipboard

Computes the z-score (standard score) of each element.

Computes the z-score (standard score) of each element in this iterable.