- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5" - Update version.txt from 4.29 → .30 (automated by Makefile)
2.0 KiB
Beta-Binomial Distribution Implementation in obistats
This Go package provides a complete statistical implementation of the Beta-Binomial distribution, a compound discrete probability distribution where the success probability of a Binomial distribution follows a Beta distribution.
Core Features
-
Struct Definition:
BetaBinomialencapsulates the distribution parameters: number of trials (N > 0) and Beta shape parametersAlphaandBeta, both strictly positive. Optional random source (Src) supports reproducible sampling. -
Probability Mass Function (PMF):
LogProb(x)computes the natural logarithm of the PMF at integerx ∈ [0, N].Prob(x)returns the PMF value via exponentiation.
-
Cumulative Distribution Function (CDF):
LogCDF(x)evaluates the log-CDF using an analytical expression involving:- Log-binomial coefficient (
Lchoose) - Log-beta function (
mathext.Lbeta) - Generalized hypergeometric function
HypPFQ(viascientificgo.org/special).
- Log-binomial coefficient (
CDF(x)returns the standard CDF asexp(LogCDF(x)).
-
Statistical Moments:
- Mean:
N \cdot \frac{\alpha}{\alpha + \beta} - Variance:
N \cdot \frac{\alpha \beta (\!N + \alpha + \beta\!)}{(\alpha+\beta)^2 (\alpha+\beta+1)} - Standard deviation: square root of variance.
- Mean:
-
Mode:
Returns the most probable count. Special cases handled:NaNif both\alpha, \beta \leq 10if only\alpha \leq 1Nif only\beta \leq 1
-
Utility Methods:
LogCDFTable(x)builds a cumulative log-probability table up tox, useful for fast lookup or numerical stability.NumParameters()returns the number of distribution parameters (3:N,\alpha,\beta).
-
Input Validation:
Panics on invalid parameters (non-positiveN,\alpha, or\beta), ensuring correctness.
This module supports high-precision statistical computations using specialized mathematical libraries (gonum.org/v1/gonum/mathext, scientificgo.org/special).