Expand description
Statistics and probability: descriptive stats, distributions, hypothesis testing, regression, Bayesian inference, random number generation, information theory.
Structs§
- Beta
Bernoulli - Beta-Bernoulli conjugate model.
- Beta
Dist - Beta distribution (Johnk’s method for sampling).
- Binomial
Dist - Binomial distribution.
- Cauchy
Dist - Cauchy distribution.
- ChiSquared
Dist - Chi-squared distribution.
- Exponential
Dist - Exponential distribution.
- Gamma
Dist - Gamma distribution (Marsaglia-Tsang method for alpha >= 1).
- Gaussian
Gaussian - Gaussian-Gaussian conjugate model (known variance).
- Lcg
- Linear Congruential Generator.
- LogNormal
Dist - Log-Normal distribution.
- Normal
Dist - Normal (Gaussian) distribution.
- Pcg32
- PCG32 — Permuted Congruential Generator.
- Poisson
Dist - Poisson distribution.
- Split
Mix64 - SplitMix64 — fast 64-bit generator suitable as seed scrambler.
- StudentT
Dist - Student’s t-distribution.
- Uniform
Dist - Continuous uniform distribution.
- Weibull
Dist - Weibull distribution.
- Xorshift64
- Xorshift64 — fast, simple 64-bit RNG.
Traits§
- Rng
- Trait for random number generators.
Functions§
- akaike_
information_ criterion - Akaike Information Criterion.
- bayesian_
information_ criterion - Bayesian Information Criterion.
- betainc
- Regularized incomplete beta function I_x(a,b).
- chi_
squared_ test - Chi-squared goodness-of-fit test. Returns (chi2-statistic, p-value).
- covariance
- Sample covariance.
- credible_
interval - Equal-tailed credible interval for Beta distribution.
- cross_
entropy - Cross-entropy H(P, Q) = -sum_x P(x) log Q(x).
- entropy
- Shannon entropy in nats (natural log base).
- erf
- Error function erf(x).
- erfc
- Complementary error function erfc(x).
- gamma
- Gamma function.
- gammainc_
lower - Regularized incomplete gamma function P(a, x) — lower.
- iqr
- Interquartile range.
- jensen_
shannon_ divergence - Jensen-Shannon divergence — symmetric, bounded [0, ln(2)].
- kl_
divergence - KL divergence D_KL(P || Q) = sum_x P(x) log(P(x)/Q(x)).
- ks_test
- Kolmogorov-Smirnov test against a theoretical CDF. Returns (D-statistic, approximate p-value).
- kurtosis
- Sample excess kurtosis.
- lgamma
- Natural log of gamma function (Lanczos approximation).
- linear_
regression - Simple linear regression: y = slope * x + intercept.
- logistic_
regression - Logistic regression via gradient descent.
xis n_samples × n_features,yis bool labels. Returns weight vector (n_features + 1, including intercept). - mann_
whitney_ u - Mann-Whitney U test (non-parametric, two-sample). Returns (U-statistic, approximate two-tailed p-value).
- mean
- Arithmetic mean.
- median
- Median (sorts the slice in place).
- mode
- Mode(s) — returns all values that appear most frequently.
- multiple_
linear_ regression - Multiple linear regression (OLS). X is n_samples × n_features. Returns coefficient vector (including intercept as first element).
- mutual_
information - Mutual information I(X;Y) from joint probability matrix.
- p_
value_ from_ chi2 - p-value from chi-squared statistic with k degrees of freedom.
- p_
value_ from_ t - Two-tailed p-value from t statistic with df degrees of freedom.
- pearson_
r - Pearson correlation coefficient.
- percentile
- p-th percentile (p in [0,100]).
- polynomial_
regression - Polynomial regression of given degree. Returns coefficients [a0, a1, …, a_deg].
- posterior_
mean - Posterior mean of Beta-Bernoulli model.
- probit
- Inverse normal CDF (probit function) via rational approximation.
- r_
squared - R-squared coefficient of determination.
- ridge_
regression - Ridge regression (L2 regularized OLS). Returns coefficients.
- sample_
without_ replacement - Sample k distinct indices from 0..n without replacement (Knuth’s algorithm S).
- shapiro_
wilk_ stat - Shapiro-Wilk test statistic W for normality. Uses first 20 a-coefficients approximation.
- shuffle
- Fisher-Yates shuffle.
- skewness
- Sample skewness.
- spearman_
rho - Spearman rank correlation.
- std_dev
- Sample standard deviation.
- t_
test_ one_ sample - One-sample t-test against mu0. Returns (t-statistic, two-tailed p-value).
- t_
test_ two_ sample - Welch’s two-sample t-test. Returns (t-statistic, two-tailed p-value).
- update_
beta_ bernoulli - Update Beta prior with new Bernoulli observations.
- variance
- Sample variance (Bessel’s correction, n-1 denominator).
- weighted_
sample - Weighted sampling — draw one index proportional to weights.