KStat is a small library for various statistical operations and probability distributions. This library is written to primarily support Kotlin and currently non-existing libraries for statistical operations. Furthermore, it provides a lightweight alternative to other libraries.
Ranges are used to represent certain values or results of operations. In particular, they are used to represent the result of a probability density function, cumulative distribution function, quantile function, etc. The following ranges are available:
Range(min: Double, max: Double)- Represents a range of values frommin(inclusive) tomax(exclusive).DiscreteRange(vararg values: Double)- Represents a discrete range (list) of values.ContinuousRange(vararg values: Double)- Represents a continuous range (list) of values.SingularRange(value: Double)- Represents a single value as a range.
All distributions offer the following methods:
getSeed(): Int- Returns the seed used for the random number generatorisDiscrete(): Boolean- Returns whether the distribution is discrete or notisContinuous(): Boolean- Returns whether the distribution is continuous or notsample(): Double- Returns a random sample from the distributionsample(n: Int): DoubleArray- Returns an array ofnrandom samples from the distributionpdf(x: Double): IRange- Returns the probability density function evaluated atxcdf(x: Double): IRange- Returns the cumulative distribution function evaluated atxquantile(p: Double): IRange- Returns the quantile function evaluated atpmean(): Double- Returns the mean of the distributionvariance(): Double- Returns the variance of the distributionstddev(): Double- Returns the standard deviation of the distributionskewness(): Double- Returns the skewness of the distributionkurtosis(): Double- Returns the kurtosis of the distributionentropy(): Double- Returns the entropy of the distributionmedian(): IRange- Returns the median of the distributionmode(): IRange- Returns the mode of the distributionmad(): Double- Returns the mean absolute deviation of the distributionmoment(n: Int): Double- Returns then-th moment of the distributionmgf(): (Int) -> Double- Returns the moment generating function of the distribution
Discrete Distributions:
- Bernoulli -
BernoulliDistribution(p: Double, seed: Int) - Binomial -
BinomialDistribution(n: Int, p: Double) - Poisson -
PoissonDistribution(rate: Int)
Continuous Distributions:
- Normal -
NormalDistribution(mean: Double, stddev: Double, seed: Int) - Uniform -
UniformDistribution(min: Double, max: Double, seed: Int) - Exponential -
ExponentialDistribution(lambda: Double, seed: Int) - Gamma -
GammaDistribution(alpha: Double, beta: Double, seed: Int) - Weibull -
WeibullDistribution(lambda: Double, k: Double, seed: Int)
The documentation can be found here. Please note that this page is a work in progress and will be updated regularly.
