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).
dnorm
Standard-normal density.
dt
Student-t density (R’s dt(x, df)).
ln_gamma
ln Γ(x) for x > 0 (Lanczos approximation, reflection below 0.5).
pt
Student-t lower-tail probability P(T ≤ t) (R’s pt(t, df)).
qnorm
Standard-normal quantile (R’s qnorm(p)), Wichura’s AS 241.
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.