DiscreteDistribution
Common interface for discrete probability distributions.
A discrete distribution assigns probabilities to individual integer outcomes via a probability mass function (PMF). Implementations provide methods to evaluate the mass, log-mass, cumulative probability, quantiles, and random sampling.
Extends Distribution, which provides shared statistical properties such as mean, variance, standardDeviation, and the sf survival function. The cdf and sf methods are available in both Int and Double overloads — the Double variants delegate to the Int versions via truncation.
Example:
val dist: DiscreteDistribution = BinomialDistribution(trials = 10, probability = 0.3)
dist.pmf(3) // 0.2668... (probability of exactly 3 successes)
dist.logPmf(3) // -1.3218... (log of the mass)
dist.cdf(3) // 0.6496... (probability of 3 or fewer successes)
dist.quantileInt(0.5) // 3 (median as Int)
dist.quantile(0.5) // 3.0 (median as Double, for Distribution compatibility)
dist.sample(Random(42)) // a single random draw
dist.sample(5, Random(42)) // five random drawsContent copied to clipboard
See also
for inherited statistical properties and survival function.
for the continuous counterpart.