BetaDistribution
Represents the Beta distribution, a continuous probability distribution defined on the interval 0, 1.
The Beta distribution is commonly used to model probabilities, proportions, and percentages because its support is naturally bounded between zero and one. It is widely used as a conjugate prior in Bayesian statistics -- for example, modeling the probability of success in a Bernoulli trial before observing data. The two shape parameters alpha and beta control the shape of the density: when both are equal, the distribution is symmetric around 0.5; when they differ, the distribution skews toward one end.
The CDF is computed via the regularized incomplete beta function, and quantiles are found using Newton's method. Random samples are generated by taking the ratio of two independent Gamma-distributed random variables.
Example:
val dist = BetaDistribution(alpha = 2.0, beta = 5.0)
dist.mean // 0.2857... (skewed toward 0)
dist.pdf(0.3) // 1.8522... (density at x = 0.3)
dist.cdf(0.5) // 0.8906... (probability of being at most 0.5)
val uniform = BetaDistribution.STANDARD
uniform.pdf(0.5) // 1.0 (flat density on [0, 1])