Probability functions: log-gamma, error function, normal distribution, and common statistical distributions (gamma, weibull, lognormal, inverse-gaussian).
Probability functions: log-gamma, error function, normal distribution, and common statistical distributions (gamma, weibull, lognormal, inverse-gaussian).
(aic k log-likelihood)Akaike Information Criterion.
AIC = 2k - 2·ln(L)
Parameters: k - number of estimated parameters log-likelihood - log-likelihood value (log(L))
Lower AIC indicates better model fit (balances goodness of fit with parsimony).
Reference: Akaike (1974), A new look at the statistical model identification.
Akaike Information Criterion. AIC = 2k - 2·ln(L) Parameters: k - number of estimated parameters log-likelihood - log-likelihood value (log(L)) Lower AIC indicates better model fit (balances goodness of fit with parsimony). Reference: Akaike (1974), A new look at the statistical model identification.
(aicc k n log-likelihood)Corrected Akaike Information Criterion for small samples.
AICc = AIC + (2k² + 2k) / (n - k - 1) = 2k - 2·ln(L) + (2k² + 2k) / (n - k - 1)
Parameters: k - number of estimated parameters n - sample size log-likelihood - log-likelihood value (log(L))
For small samples (n/k < 40), AICc should be used instead of AIC. As n → ∞, AICc → AIC.
Requires n > k + 1 to avoid division by zero.
Reference: Hurvich & Tsai (1989), Regression and time series model selection in small samples.
Corrected Akaike Information Criterion for small samples.
AICc = AIC + (2k² + 2k) / (n - k - 1)
= 2k - 2·ln(L) + (2k² + 2k) / (n - k - 1)
Parameters:
k - number of estimated parameters
n - sample size
log-likelihood - log-likelihood value (log(L))
For small samples (n/k < 40), AICc should be used instead of AIC.
As n → ∞, AICc → AIC.
Requires n > k + 1 to avoid division by zero.
Reference: Hurvich & Tsai (1989), Regression and time series model
selection in small samples.(bic k n log-likelihood)Bayesian Information Criterion (Schwarz criterion).
BIC = k·ln(n) - 2·ln(L)
Parameters: k - number of estimated parameters n - sample size log-likelihood - log-likelihood value (log(L))
Lower BIC indicates better model fit. BIC penalizes model complexity more heavily than AIC for n ≥ 8.
Reference: Schwarz (1978), Estimating the dimension of a model.
Bayesian Information Criterion (Schwarz criterion). BIC = k·ln(n) - 2·ln(L) Parameters: k - number of estimated parameters n - sample size log-likelihood - log-likelihood value (log(L)) Lower BIC indicates better model fit. BIC penalizes model complexity more heavily than AIC for n ≥ 8. Reference: Schwarz (1978), Estimating the dimension of a model.
(cvm-pvalue w2-statistic n)Compute asymptotic p-value for Cramér-von Mises test.
Uses the approximation from Csörgő & Faraway (1996) for the limiting distribution of W².
Parameters: w2-statistic - the W² statistic from cvm-test-statistic n - sample size
Returns the p-value.
Compute asymptotic p-value for Cramér-von Mises test. Uses the approximation from Csörgő & Faraway (1996) for the limiting distribution of W². Parameters: w2-statistic - the W² statistic from cvm-test-statistic n - sample size Returns the p-value.
(cvm-test samples cdf-fn)One-sample Cramér-von Mises goodness-of-fit test.
Tests whether the sample comes from the specified distribution. The null hypothesis is that the sample is drawn from the theoretical distribution.
W² is more sensitive to differences in the tails than K-S, and gives equal weight to all parts of the distribution.
Requires a typed array (DoubleArray, LongArray).
Parameters: samples - typed array of sample values cdf-fn - theoretical CDF function (e.g., (gamma-cdf shape scale))
Returns map with: :statistic - the W² statistic :p-value - asymptotic p-value :n - sample size
A small p-value suggests the sample does not come from the specified distribution.
Reference: Cramér (1928), On the composition of elementary errors; von Mises (1931), Wahrscheinlichkeitsrechnung.
One-sample Cramér-von Mises goodness-of-fit test.
Tests whether the sample comes from the specified distribution.
The null hypothesis is that the sample is drawn from the theoretical distribution.
W² is more sensitive to differences in the tails than K-S, and gives
equal weight to all parts of the distribution.
Requires a typed array (DoubleArray, LongArray).
Parameters:
samples - typed array of sample values
cdf-fn - theoretical CDF function (e.g., (gamma-cdf shape scale))
Returns map with:
:statistic - the W² statistic
:p-value - asymptotic p-value
:n - sample size
A small p-value suggests the sample does not come from the specified distribution.
Reference: Cramér (1928), On the composition of elementary errors;
von Mises (1931), Wahrscheinlichkeitsrechnung.(cvm-test-statistic samples cdf-fn)Compute the Cramér-von Mises W² statistic.
W² = (1/12n) + Σᵢ₌₁ⁿ [F(xᵢ) - (2i-1)/(2n)]²
Requires a typed array (DoubleArray, LongArray).
Parameters: samples - typed array of sample values cdf-fn - theoretical CDF function
Returns the W² statistic.
Compute the Cramér-von Mises W² statistic. W² = (1/12n) + Σᵢ₌₁ⁿ [F(xᵢ) - (2i-1)/(2n)]² Requires a typed array (DoubleArray, LongArray). Parameters: samples - typed array of sample values cdf-fn - theoretical CDF function Returns the W² statistic.
(digamma x)Compute the digamma function ψ(x) = d/dx ln(Γ(x)) = Γ'(x)/Γ(x).
Uses the asymptotic expansion for large x and recurrence relation for small x. Accurate to ~15 digits for x > 0.
Special cases:
Reference: Bernardo (1976), Algorithm AS 103: Psi (Digamma) Function
Compute the digamma function ψ(x) = d/dx ln(Γ(x)) = Γ'(x)/Γ(x). Uses the asymptotic expansion for large x and recurrence relation for small x. Accurate to ~15 digits for x > 0. Special cases: - x ≤ 0: throws IllegalArgumentException Reference: Bernardo (1976), Algorithm AS 103: Psi (Digamma) Function
(erf x)erf polynomial approximation. Maximum error is 1.5e-7. Handbook of Mathematical Functions: with Formulas, Graphs, and Mathematical Tables. Milton Abramowitz (Editor), Irene A. Stegun (Editor), 7.1.26
erf polynomial approximation. Maximum error is 1.5e-7. Handbook of Mathematical Functions: with Formulas, Graphs, and Mathematical Tables. Milton Abramowitz (Editor), Irene A. Stegun (Editor), 7.1.26
(gamma-cdf shape scale)Cumulative distribution function for the gamma distribution.
Parameters: shape (k) - shape parameter, must be > 0 scale (θ) - scale parameter, must be > 0
Returns a function F(x) that computes P(X ≤ x). Uses the regularized incomplete gamma function.
Cumulative distribution function for the gamma distribution. Parameters: shape (k) - shape parameter, must be > 0 scale (θ) - scale parameter, must be > 0 Returns a function F(x) that computes P(X ≤ x). Uses the regularized incomplete gamma function.
(gamma-pdf shape scale)Probability density function for the gamma distribution.
Parameters: shape (k) - shape parameter, must be > 0 scale (θ) - scale parameter, must be > 0
Returns a function f(x) that computes the density at x. f(x) = x^(k-1) * e^(-x/θ) / (θ^k * Γ(k)) for x > 0
Probability density function for the gamma distribution. Parameters: shape (k) - shape parameter, must be > 0 scale (θ) - scale parameter, must be > 0 Returns a function f(x) that computes the density at x. f(x) = x^(k-1) * e^(-x/θ) / (θ^k * Γ(k)) for x > 0
(inverse-gaussian-cdf mu lambda)Cumulative distribution function for the inverse Gaussian distribution.
Parameters: mu (μ) - mean parameter, must be > 0 lambda (λ) - shape parameter, must be > 0
Returns a function F(x) that computes P(X ≤ x). F(x) = Φ(√(λ/x)(x/μ - 1)) + e^(2λ/μ) * Φ(-√(λ/x)(x/μ + 1))
Cumulative distribution function for the inverse Gaussian distribution. Parameters: mu (μ) - mean parameter, must be > 0 lambda (λ) - shape parameter, must be > 0 Returns a function F(x) that computes P(X ≤ x). F(x) = Φ(√(λ/x)*(x/μ - 1)) + e^(2λ/μ) * Φ(-√(λ/x)*(x/μ + 1))
(inverse-gaussian-pdf mu lambda)Probability density function for the inverse Gaussian distribution.
Parameters: mu (μ) - mean parameter, must be > 0 lambda (λ) - shape parameter, must be > 0
Returns a function f(x) that computes the density at x. f(x) = √(λ/(2πx³)) * e^(-λ(x-μ)²/(2μ²x)) for x > 0
Probability density function for the inverse Gaussian distribution. Parameters: mu (μ) - mean parameter, must be > 0 lambda (λ) - shape parameter, must be > 0 Returns a function f(x) that computes the density at x. f(x) = √(λ/(2πx³)) * e^(-λ(x-μ)²/(2μ²x)) for x > 0
(ks-pvalue d-statistic n)Compute asymptotic p-value for Kolmogorov-Smirnov test.
Uses the asymptotic distribution: √n·D converges to the Kolmogorov distribution. P-value = 1 - K(√n · D) where K is the Kolmogorov CDF.
Parameters: d-statistic - the D statistic from ks-test-statistic n - sample size
Returns the two-sided p-value.
Compute asymptotic p-value for Kolmogorov-Smirnov test. Uses the asymptotic distribution: √n·D converges to the Kolmogorov distribution. P-value = 1 - K(√n · D) where K is the Kolmogorov CDF. Parameters: d-statistic - the D statistic from ks-test-statistic n - sample size Returns the two-sided p-value.
(ks-test samples cdf-fn)One-sample Kolmogorov-Smirnov goodness-of-fit test.
Tests whether the sample comes from the specified distribution. The null hypothesis is that the sample is drawn from the theoretical distribution.
Requires a typed array (DoubleArray, LongArray).
Parameters: samples - typed array of sample values cdf-fn - theoretical CDF function (e.g., (gamma-cdf shape scale))
Returns map with: :statistic - the D statistic (maximum difference between empirical and theoretical CDFs) :p-value - asymptotic two-sided p-value :n - sample size
A small p-value suggests the sample does not come from the specified distribution.
Reference: Kolmogorov (1933), Sulla determinazione empirica di una legge di distribuzione; Smirnov (1948), Table for estimating the goodness of fit of empirical distributions.
One-sample Kolmogorov-Smirnov goodness-of-fit test.
Tests whether the sample comes from the specified distribution.
The null hypothesis is that the sample is drawn from the theoretical distribution.
Requires a typed array (DoubleArray, LongArray).
Parameters:
samples - typed array of sample values
cdf-fn - theoretical CDF function (e.g., (gamma-cdf shape scale))
Returns map with:
:statistic - the D statistic (maximum difference between empirical and theoretical CDFs)
:p-value - asymptotic two-sided p-value
:n - sample size
A small p-value suggests the sample does not come from the specified distribution.
Reference: Kolmogorov (1933), Sulla determinazione empirica di una legge
di distribuzione; Smirnov (1948), Table for estimating the
goodness of fit of empirical distributions.(ks-test-statistic samples cdf-fn)Compute the Kolmogorov-Smirnov D statistic.
D = max|Fₙ(x) - F(x)|
where Fₙ is the empirical CDF and F is the theoretical CDF.
Requires a typed array (DoubleArray, LongArray).
Parameters: samples - typed array of sample values cdf-fn - theoretical CDF function (e.g., from gamma-cdf, weibull-cdf)
Returns the D statistic.
Compute the Kolmogorov-Smirnov D statistic. D = max|Fₙ(x) - F(x)| where Fₙ is the empirical CDF and F is the theoretical CDF. Requires a typed array (DoubleArray, LongArray). Parameters: samples - typed array of sample values cdf-fn - theoretical CDF function (e.g., from gamma-cdf, weibull-cdf) Returns the D statistic.
(log-gamma x)Compute the natural logarithm of the gamma function using Lanczos approximation. Returns ln(Γ(x)) for x > 0.
Uses the Lanczos approximation with g=7 and 9 coefficients, providing approximately 15 digits of precision. Matches R's lgamma() behavior.
Special cases:
Reference: Numerical Recipes 3rd ed., section 6.1
Compute the natural logarithm of the gamma function using Lanczos approximation. Returns ln(Γ(x)) for x > 0. Uses the Lanczos approximation with g=7 and 9 coefficients, providing approximately 15 digits of precision. Matches R's lgamma() behavior. Special cases: - x ≤ 0: throws IllegalArgumentException - x = 1 or x = 2: returns 0.0 (since Γ(1) = Γ(2) = 1) Reference: Numerical Recipes 3rd ed., section 6.1
(lognormal-cdf mu sigma)Cumulative distribution function for the log-normal distribution.
Parameters: mu (μ) - mean of the underlying normal distribution (log scale) sigma (σ) - standard deviation of the underlying normal, must be > 0
Returns a function F(x) that computes P(X ≤ x). F(x) = Φ((ln(x) - μ) / σ) for x > 0
Cumulative distribution function for the log-normal distribution. Parameters: mu (μ) - mean of the underlying normal distribution (log scale) sigma (σ) - standard deviation of the underlying normal, must be > 0 Returns a function F(x) that computes P(X ≤ x). F(x) = Φ((ln(x) - μ) / σ) for x > 0
(lognormal-pdf mu sigma)Probability density function for the log-normal distribution.
Parameters: mu (μ) - mean of the underlying normal distribution (log scale) sigma (σ) - standard deviation of the underlying normal, must be > 0
Returns a function f(x) that computes the density at x. f(x) = 1/(xσ√(2π)) * e^(-(ln(x)-μ)²/(2σ²)) for x > 0
Probability density function for the log-normal distribution. Parameters: mu (μ) - mean of the underlying normal distribution (log scale) sigma (σ) - standard deviation of the underlying normal, must be > 0 Returns a function f(x) that computes the density at x. f(x) = 1/(x*σ*√(2π)) * e^(-(ln(x)-μ)²/(2σ²)) for x > 0
(normal-cdf x)Probability p(X<x), for a normal distrubtion. Uses the polynomial erf approximation above, and so is not super accurate.
Probability p(X<x), for a normal distrubtion. Uses the polynomial erf approximation above, and so is not super accurate.
(normal-pdf mu sigma)Probability density function for the normal distribution.
Probability density function for the normal distribution.
(normal-quantile x)Normal quantile function. Given a quantile in (0,1), return the normal value for that quantile.
Wichura, MJ. 'Algorithm AS241' The Percentage Points of the Normal Distribution. Applied Statistics, 37, 477-484
Normal quantile function. Given a quantile in (0,1), return the normal value for that quantile. Wichura, MJ. 'Algorithm AS241' The Percentage Points of the Normal Distribution. Applied Statistics, 37, 477-484
(polynomial-value x coefficients)Evaluate a polynomial at the given value x, for the coefficients given in descending order (so the last element of coefficients is the constant term).
Evaluate a polynomial at the given value x, for the coefficients given in descending order (so the last element of coefficients is the constant term).
(regularized-gamma-p a x)Regularized lower incomplete gamma function P(a, x) = γ(a,x) / Γ(a). Uses series expansion for small x, continued fraction for large x.
This is the CDF of the gamma distribution with shape=a and scale=1.
Reference: Numerical Recipes 3rd ed., section 6.2
Regularized lower incomplete gamma function P(a, x) = γ(a,x) / Γ(a). Uses series expansion for small x, continued fraction for large x. This is the CDF of the gamma distribution with shape=a and scale=1. Reference: Numerical Recipes 3rd ed., section 6.2
(trigamma x)Compute the trigamma function ψ'(x) = d²/dx² ln(Γ(x)).
Uses the asymptotic expansion for large x and recurrence relation for small x. Accurate to ~15 digits for x > 0.
Special cases:
Reference: Schneider (1978), Algorithm AS 121: Trigamma Function
Compute the trigamma function ψ'(x) = d²/dx² ln(Γ(x)). Uses the asymptotic expansion for large x and recurrence relation for small x. Accurate to ~15 digits for x > 0. Special cases: - x ≤ 0: throws IllegalArgumentException Reference: Schneider (1978), Algorithm AS 121: Trigamma Function
(weibull-cdf shape scale)Cumulative distribution function for the Weibull distribution.
Parameters: shape (k) - shape parameter, must be > 0 scale (λ) - scale parameter, must be > 0
Returns a function F(x) that computes P(X ≤ x). F(x) = 1 - e^(-(x/λ)^k) for x > 0
Cumulative distribution function for the Weibull distribution. Parameters: shape (k) - shape parameter, must be > 0 scale (λ) - scale parameter, must be > 0 Returns a function F(x) that computes P(X ≤ x). F(x) = 1 - e^(-(x/λ)^k) for x > 0
(weibull-pdf shape scale)Probability density function for the Weibull distribution.
Parameters: shape (k) - shape parameter, must be > 0 scale (λ) - scale parameter, must be > 0
Returns a function f(x) that computes the density at x. f(x) = (k/λ) * (x/λ)^(k-1) * e^(-(x/λ)^k) for x > 0
Probability density function for the Weibull distribution. Parameters: shape (k) - shape parameter, must be > 0 scale (λ) - scale parameter, must be > 0 Returns a function f(x) that computes the density at x. f(x) = (k/λ) * (x/λ)^(k-1) * e^(-(x/λ)^k) for x > 0
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |