Skip to main content

Module distribution

Module distribution 

Source
Expand description

Self-contained quantile / density functions for the theoretical distributions of stat_qq / stat_qq_band (normal, Student t, exponential, half-normal).

These must work in every feature configuration — including the minimal, plotters-free --no-default-features build used by the DuckDB extensions — so they don’t depend on the optional regression feature’s distribution library. Accuracy (checked against R in the tests):

  • qnorm: Wichura’s AS 241 (PPND16), ~1e-16 relative;
  • pt / qt: regularized incomplete beta (Lentz continued fraction) and a safeguarded Newton inversion, ~1e-12;
  • ln_gamma: Lanczos (g = 7, n = 9), ~1e-15.

Functions§

beta_inc
Regularized incomplete beta I_x(a, b).
dbeta
Beta(a, b): density, lower-tail probability, quantile.
dgamma
Gamma(shape, rate): density, lower-tail probability, quantile.
dlnorm
LogNormal(meanlog, sdlog): density, lower-tail probability, quantile.
dnorm
Standard-normal density.
dnorm_ms
Normal(mean, sd): density, lower-tail probability, quantile.
dt
Student-t density (R’s dt(x, df)).
gamma_inc
Regularized lower incomplete gamma P(a, x) (series below a + 1, continued fraction above; Numerical Recipes gammp).
ln_gamma
ln Γ(x) for x > 0 (Lanczos approximation, reflection below 0.5).
pbeta
pgamma
plnorm
pnorm
Standard-normal lower-tail probability Φ(x) (via the complementary error function, |error| < 1.2e-7).
pnorm_ms
pt
Student-t lower-tail probability P(T ≤ t) (R’s pt(t, df)).
qbeta
qgamma
qlnorm
qnorm
Standard-normal quantile (R’s qnorm(p)), Wichura’s AS 241.
qnorm_ms
qt
Student-t quantile for any p (R’s qt(p, df)): closed forms for df = 1, 2, otherwise a bracketed Newton inversion of pt.