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 from min
(inclusive) to max
(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 of n
random samples from the distributionpdf(x: Double): IRange
- Returns the probability density function evaluated at x
cdf(x: Double): IRange
- Returns the cumulative distribution function evaluated at x
quantile(p: Double): IRange
- Returns the quantile function evaluated at p
mean(): 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 the n
-th moment of the distributionmgf(): (Int) -> Double
- Returns the moment generating function of the distributionDiscrete Distributions:
BernoulliDistribution(p: Double, seed: Int)
BinomialDistribution(n: Int, p: Double)
PoissonDistribution(rate: Int)
Continuous Distributions:
NormalDistribution(mean: Double, stddev: Double, seed: Int)
UniformDistribution(min: Double, max: Double, seed: Int)
ExponentialDistribution(lambda: Double, seed: Int)
GammaDistribution(alpha: Double, beta: Double, seed: Int)
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.