Skip to main content
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

The Gaussian distribution. Models data that clusters symmetrically around a mean with a characteristic bell-shaped curve.Parameters: mu — mean, sigma — standard deviation (must be positive)
Use when data is approximately symmetric and unbounded.
Heavier tails than the normal distribution. Approaches the normal as degrees of freedom increase.Parameters: df — degrees of freedom (must be positive)
Use for confidence intervals and t-tests when the sample size is small.
Similar shape to the normal but with heavier tails. The CDF has a closed-form logistic function.Parameters: location — center, scale — spread parameter (must be positive)
Use when a closed-form CDF is needed or data has slightly heavier tails than normal.
Extremely heavy tails. The mean and variance are undefined.Parameters: location — center (median), scale — half-width at half-maximum (must be positive)
Use for data with extreme outliers where the mean is not a meaningful summary.
Double-exponential distribution. Sharper peak and heavier tails than the normal.Parameters: location — center (mean and median), scale — spread parameter (must be positive)
Use for data with a sharp peak at the center and exponential tails.

Discrete Distributions

Models the number of events in a fixed interval when events occur independently at a constant rate.Parameters: lambda — expected number of events (must be positive)
Use for count data: defects per batch, arrivals per hour, events per day.
Models the number of successes in a fixed number of independent Bernoulli trials.Parameters: trials — number of trials (must be non-negative), probability — success probability per trial (must be in [0, 1])
Use for yes/no experiments repeated a known number of times.
Models the number of failures before achieving a specified number of successes.Parameters: r — number of successes (must be positive), p — success probability (must be in (0, 1])
Use for over-dispersed count data or modeling the number of trials until a target is reached.
Models the number of trials until the first success. A special case of the negative binomial.Parameters: probability — success probability per trial (must be in (0, 1])
Use for “how many tries until it works” questions.

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.
Last modified on April 18, 2026