kstats-distributions provides a unified API for continuous and discrete probability models. Every distribution supports the same workflow: construct with parameters, inspect statistical properties, evaluate probabilities, compute quantiles, and draw random samples.
Working with a Distribution
Shared API
Every distribution implements common statistical properties:mean, variance, standardDeviation, skewness, kurtosis, and entropy.
The evaluation methods differ between continuous and discrete distributions:
Constructors validate parameters eagerly. Invalid values (negative standard deviation, probability outside [0, 1], non-positive degrees of freedom) throw
InvalidParameterException at construction time, not at evaluation.Continuous Distributions
- Symmetric / General-Purpose
- Positive Real-Valued
- Bounded
- Extreme Value / Heavy-Tailed
NormalDistribution(mu, sigma)
NormalDistribution(mu, sigma)
The Gaussian distribution. Models data that clusters symmetrically around a mean with a characteristic bell-shaped curve.Parameters: Use when data is approximately symmetric and unbounded.
mu — mean, sigma — standard deviation (must be positive)StudentTDistribution(degreesOfFreedom)
StudentTDistribution(degreesOfFreedom)
Heavier tails than the normal distribution. Approaches the normal as degrees of freedom increase.Parameters: Use for confidence intervals and t-tests when the sample size is small.
df — degrees of freedom (must be positive)LogisticDistribution(mu, scale)
LogisticDistribution(mu, scale)
Similar shape to the normal but with heavier tails. The CDF has a closed-form logistic function.Parameters: Use when a closed-form CDF is needed or data has slightly heavier tails than normal.
location — center, scale — spread parameter (must be positive)CauchyDistribution(location, scale)
CauchyDistribution(location, scale)
Extremely heavy tails. The mean and variance are undefined.Parameters: Use for data with extreme outliers where the mean is not a meaningful summary.
location — center (median), scale — half-width at half-maximum (must be positive)LaplaceDistribution(mu, scale)
LaplaceDistribution(mu, scale)
Double-exponential distribution. Sharper peak and heavier tails than the normal.Parameters: Use for data with a sharp peak at the center and exponential tails.
location — center (mean and median), scale — spread parameter (must be positive)Discrete Distributions
- Count / Event
- Sampling / Compound
- Simple / Uniform
- Heavy-Tailed / Rank
PoissonDistribution(rate)
PoissonDistribution(rate)
Models the number of events in a fixed interval when events occur independently at a constant rate.Parameters: Use for count data: defects per batch, arrivals per hour, events per day.
lambda — expected number of events (must be positive)BinomialDistribution(trials, probability)
BinomialDistribution(trials, probability)
Models the number of successes in a fixed number of independent Bernoulli trials.Parameters: Use for yes/no experiments repeated a known number of times.
trials — number of trials (must be non-negative), probability — success probability per trial (must be in [0, 1])NegativeBinomialDistribution(successes, probability)
NegativeBinomialDistribution(successes, probability)
Models the number of failures before achieving a specified number of successes.Parameters: Use for over-dispersed count data or modeling the number of trials until a target is reached.
r — number of successes (must be positive), p — success probability (must be in (0, 1])GeometricDistribution(probability)
GeometricDistribution(probability)
Models the number of trials until the first success. A special case of the negative binomial.Parameters: Use for “how many tries until it works” questions.
probability — success probability per trial (must be in (0, 1])Choosing a Distribution
When unsure, start with
NormalDistribution for continuous data and PoissonDistribution for counts. These are the most common defaults and serve as reasonable baselines.API Reference
Full API Reference
Browse all distribution constructors, methods, and properties in the Dokka-generated reference.