Distribution

sealed interface Distribution(source)

Represents the common sealed interface for all probability distributions in kstats.

Every probability distribution — whether continuous or discrete — extends this interface, which provides shared statistical properties such as the mean, variance, standard deviation, skewness, kurtosis, and entropy. It also declares the cumulative distribution function (CDF), the survival function (SF), and the quantile (inverse CDF) function.

Concrete distributions do not implement this interface directly. Instead, they implement either ContinuousDistribution or DiscreteDistribution, both of which extend Distribution with type-specific methods like pdf/pmf and sample.

Example:

val dist: Distribution = NormalDistribution(mu = 0.0, sigma = 1.0)
dist.mean // 0.0
dist.variance // 1.0
dist.standardDeviation // 1.0
dist.cdf(0.0) // 0.5 (half the probability mass is below the mean)
dist.sf(0.0) // 0.5 (survival function, complement of cdf)
dist.quantile(0.975) // 1.96 (the value below which 97.5% of the mass lies)

See also

for distributions defined over real-valued intervals.

for distributions defined over integer-valued outcomes.

Inheritors

Properties

Link copied to clipboard
abstract val entropy: Double

The Shannon entropy of this distribution in nats (natural logarithm units), measuring the uncertainty or spread of the distribution.

Link copied to clipboard
abstract val kurtosis: Double

The excess kurtosis (fourth standardized moment minus 3) of this distribution, measuring the heaviness of the tails relative to a normal distribution. Zero for normal, positive for heavier tails.

Link copied to clipboard
abstract val mean: Double

The expected value (first moment) of this distribution.

Link copied to clipboard
abstract val skewness: Double

The skewness (third standardized moment) of this distribution, measuring asymmetry around the mean. Zero for symmetric distributions, positive for right-skewed, negative for left-skewed.

Link copied to clipboard

The standard deviation of this distribution, equal to the square root of variance.

Link copied to clipboard
abstract val variance: Double

The variance (second central moment) of this distribution, measuring how spread out values are around the mean.

Functions

Link copied to clipboard
abstract fun cdf(x: Double): Double

Computes the cumulative distribution function (CDF) at the given point.

Link copied to clipboard
abstract fun quantile(p: Double): Double

Computes the quantile (inverse CDF) for the given cumulative probability.

Link copied to clipboard
open fun sf(x: Double): Double

Computes the survival function (SF) at the given point.