Stochastic
Monte Carlo, synthetic data, and what-if analysis directly in SQL.
On this page
Technical Overview
22 distributions, callable from a SELECT
22 named probability distributions, each callable from DuckDB SQL — PDF, CDF, quantile, hazard, and random sampling for 22 named distributions, all under a uniform dist_<family>_<op> naming scheme. Built for Monte Carlo sketches, what-if analysis, and synthetic data generation without leaving SQL.
What it is
A complete statistical-distributions library exposed as scalar SQL functions. The usual reason to leave SQL for statistics is that the math lives somewhere else — you export rows into NumPy or pandas, compute a CDF or draw samples, and bring the result back. Stochastic puts that math where the rows already are: probability calculations become ordinary expressions that chain with joins, window functions, CTEs, and CREATE TABLE AS. It is the right tool for ad-hoc analysis, Monte Carlo sketches, synthetic data, and inline p-values that live next to your warehouse data — not a replacement for a full simulation or model-fitting stack.
How it works
The extension wraps the Boost.Math statistical-distributions library — the same battle-tested implementations used across C++ statistics tooling. Each of the 22 distributions exposes the same ~21-operation surface (sampling, density, cumulative, quantile, hazard, and the distribution moments and properties), and that whole surface is generated from a single template. The payoff is uniformity: once you know one distribution's functions you know all of them, since the family name simply swaps in the function name.
-
•
Vectorized scalar execution: Every function is a scalar that runs column-at-a-time over DuckDB's columnar engine. A million sampling calls inside a
SELECTis one vectorized scan, not a Python loop — so Monte Carlo overrange(N)stays fast. -
•
Strict input validation: Illegal parameters (a negative standard deviation, a probability above 1) raise a SQL error rather than silently returning
NaN, so a typo in a long pipeline fails fast instead of quietly poisoning every downstream value.
Scope and honest caveats
A deep distributions library, but intentionally not a full simulation framework.
- • Univariate only: No copula or multivariate-normal sampler. For correlated draws, sample independently and apply a Cholesky-style transform yourself.
- • RNG seeding is not user-controlled: There is no documented per-query seed. For exactly-reproducible runs, generate the draws once into a table and treat that table as the seed.
- • No fitting or inference helpers: One-way: parameters → distribution. No MLE / method-of-moments fitters, no built-in tests. Compute the test statistic in SQL and call the appropriate CDF complement for the p-value.
- • Large simulations may want a notebook: For large-scale agent-based simulation, MCMC, or SciPy-grade fitting, keep a Python notebook. Stochastic shines for analyses that live next to warehouse data.
Deep Dive
Technical Details
What you can do with one query
Estimate π with a million-draw Monte Carlo — entirely inside DuckDB, no Python, no NumPy:
WITH samples AS ( SELECT dist_uniform_real_sample(-1.0, 1.0) AS x, dist_uniform_real_sample(-1.0, 1.0) AS y FROM range(1000000))SELECT 4.0 * COUNT(*) FILTER (WHERE x*x + y*y <= 1) / COUNT(*) AS pi_estimateFROM samples;The same shape — generate, filter, aggregate — handles portfolio VaR, payoff integration, queueing simulation, or generating a million-row synthetic dataset for a load test. Every dist_<family>_sample is a vectorized scalar function, so a million draws is one columnar scan.
This extension is a statistical-distributions library, not a full simulation framework. It covers the 22 most common distributions with the full PDF / CDF / quantile / hazard / sampling / properties surface — built on the Boost.Math distributions library.
What it deliberately doesn’t ship:
- No copulas / multivariate distributions. The 22 families are univariate; correlated draws need a Cholesky-style transform you write yourself.
- No user-controlled RNG seed. For exactly-reproducible runs, materialize the draws into a table and treat that as the seed.
- No fitters or hypothesis-test wrappers. Compute the test statistic in SQL, then call the appropriate
_cdf_complementfor the p-value.
For production-grade simulation, MCMC, or anything needing SciPy-level fitting, keep a Python notebook with NumPy and SciPy. For quick analysis, what-if exploration, and synthetic data right next to your warehouse data, this is the right tool.
What this extension covers
22 named probability distributions — 16 continuous, 6 discrete — each exposed through the same uniform set of operations:
- Sampling (
_sample) — draw a random value. - Density / mass (
_pdf,_log_pdf) — point density. - Cumulative (
_cdf,_log_cdf,_cdf_complement,_log_cdf_complement) — left tail and survival. - Quantile (
_quantile,_quantile_complement) — inverse CDF. - Hazard (
_hazard,_chf) — instantaneous and cumulative hazard. - Properties (
_mean,_median,_mode,_variance,_stddev,_skewness,_kurtosis,_kurtosis_excess,_range,_support).
The same naming scheme across all 22 means once you know one distribution’s surface you know them all. Browse the categories sidebar to jump straight to the distribution you need.
Why DuckDB instead of Python / R / Excel?
- No data movement. Stats happen where the rows live — no export to NumPy or pandas just to compute a CDF.
- Vectorized. All functions run column-at-a-time over DuckDB’s columnar engine.
- SQL composition. Probability calculations chain cleanly with joins, window functions, CTEs, and CTAS.
- Reproducibility. A
WITHclause containing distribution functions is a complete, self-describing analysis you can paste into any DuckDB session.
Parameter validation
Every function validates its parameters and raises a SQL error on illegal inputs — no silent NaN propagation:
SELECT dist_normal_pdf(0.0, -1.0, 0.5);-- Error: normal: Standard deviation must be > 0 was: -1.000000
SELECT dist_binomial_pdf(10, 1.5, 5);-- Error: binomial: Probability must be between 0 and 1 was: 1.500000When to use which family
| Pick this when… | Reach for |
|---|---|
| Test scores, measurement noise, anything CLT-flavoured | Normal |
| Small-sample inference (df ≤ 30) | Student’s t |
| Counts of independent events at a rate | Poisson |
| Yes/no per-trial outcomes | Bernoulli, Binomial |
| Time between events / time-to-failure | Exponential, Weibull |
| Heavy-tailed wealth or file-size data | Pareto, Cauchy, Log-normal |
| Bayesian priors over probabilities | Beta |
| Ratios of variances (ANOVA / regression) | Fisher F |
| Goodness-of-fit, variance tests | Chi-squared |
| Block maxima / rare-event tails | Extreme Value |
| Robust regression / sparse priors | Laplace |
| Inverse-transform sampling, dice, random index | Uniform (Real), Uniform (Integer) |
Install
INSTALL stochastic FROM community;
LOAD stochastic;
Quick Start
Find the 95th percentile of a Normal(0, 1)
SELECT dist_normal_quantile(0.0, 1.0, 0.95) AS p95;
1,000 random draws from N(100, 15)
SELECT dist_normal_sample(100.0, 15.0) AS x
FROM range(1000);
P(X ≤ 5 | Binomial(n=10, p=0.3))
SELECT dist_binomial_cdf(10, 0.3, 5) AS prob_at_most_5;
Reference
Extension Contents
Quick reference to all available functions and settings organized by category.
| Name | Type | Description |
|---|---|---|
|
Bernoulli
Bernoulli — single yes/no trial with success probability p. Foundation of every binary outcome model. |
||
| dist_bernoulli_cdf() | Computes the cumulative distribution function (CDF) of the bernoulli distribution. | |
| dist_bernoulli_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the bernoulli distribution. | |
| dist_bernoulli_chf() | Computes the cumulative hazard function of the bernoulli distribution. | |
| dist_bernoulli_hazard() | Computes the hazard function of the bernoulli distribution. | |
| dist_bernoulli_kurtosis() | Returns the kurtosis of the bernoulli distribution. | |
| dist_bernoulli_kurtosis_excess() | Returns the excess kurtosis of the bernoulli distribution. | |
| dist_bernoulli_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the bernoulli distribution. | |
| dist_bernoulli_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the bernoulli distribution. | |
| dist_bernoulli_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the bernoulli distribution. | |
| dist_bernoulli_mean() | Returns the mean (μ) of the bernoulli distribution, which is the first moment. | |
| dist_bernoulli_median() | Returns the median (50th percentile) of the bernoulli distribution, which equals the mean. | |
| dist_bernoulli_mode() | Returns the mode (most likely value) of the bernoulli distribution, which equals the mean. | |
| dist_bernoulli_pdf() | Computes the probability density function (PDF) of the bernoulli distribution. | |
| dist_bernoulli_quantile() | Computes the quantile function (inverse CDF) of the bernoulli distribution. | |
| dist_bernoulli_quantile_complement() | Computes the complementary quantile function of the bernoulli distribution. | |
| dist_bernoulli_range() | Returns the range of the bernoulli distribution. | |
| dist_bernoulli_sample() | Generates random samples from the bernoulli distribution with specified parameters. | |
| dist_bernoulli_skewness() | Returns the skewness of the bernoulli distribution. | |
| dist_bernoulli_stddev() | Returns the standard deviation (σ) of the bernoulli distribution. | |
| dist_bernoulli_support() | Returns the support of the bernoulli distribution. | |
| dist_bernoulli_variance() | Returns the variance (σ²) of the bernoulli distribution. | |
|
Beta
Beta distribution on [0,1] — shape parameters α, β. Common for Bayesian priors over probabilities and modeling proportions. |
||
| dist_beta_cdf() | Computes the cumulative distribution function (CDF) of the beta distribution. | |
| dist_beta_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the beta distribution. | |
| dist_beta_chf() | Computes the cumulative hazard function of the beta distribution. | |
| dist_beta_hazard() | Computes the hazard function of the beta distribution. | |
| dist_beta_kurtosis() | Returns the kurtosis of the beta distribution. | |
| dist_beta_kurtosis_excess() | Returns the excess kurtosis of the beta distribution. | |
| dist_beta_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the beta distribution. | |
| dist_beta_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the beta distribution. | |
| dist_beta_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the beta distribution. | |
| dist_beta_mean() | Returns the mean (μ) of the beta distribution, which is the first moment. | |
| dist_beta_median() | Returns the median (50th percentile) of the beta distribution, which equals the mean. | |
| dist_beta_mode() | Returns the mode (most likely value) of the beta distribution, which equals the mean. | |
| dist_beta_pdf() | Computes the probability density function (PDF) of the beta distribution. | |
| dist_beta_quantile() | Computes the quantile function (inverse CDF) of the beta distribution. | |
| dist_beta_quantile_complement() | Computes the complementary quantile function of the beta distribution. | |
| dist_beta_range() | Returns the range of the beta distribution. | |
| dist_beta_sample() | Generates random samples from the beta distribution with specified parameters. | |
| dist_beta_skewness() | Returns the skewness of the beta distribution. | |
| dist_beta_stddev() | Returns the standard deviation (σ) of the beta distribution. | |
| dist_beta_support() | Returns the support of the beta distribution. | |
| dist_beta_variance() | Returns the variance (σ²) of the beta distribution. | |
|
Binomial
Binomial — number of successes in n independent Bernoulli trials at probability p. |
||
| dist_binomial_cdf() | Computes the cumulative distribution function (CDF) of the binomial distribution. | |
| dist_binomial_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the binomial distribution. | |
| dist_binomial_chf() | Computes the cumulative hazard function of the binomial distribution. | |
| dist_binomial_hazard() | Computes the hazard function of the binomial distribution. | |
| dist_binomial_kurtosis() | Returns the kurtosis of the binomial distribution. | |
| dist_binomial_kurtosis_excess() | Returns the excess kurtosis of the binomial distribution. | |
| dist_binomial_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the binomial distribution. | |
| dist_binomial_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the binomial distribution. | |
| dist_binomial_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the binomial distribution. | |
| dist_binomial_median() | Returns the median (50th percentile) of the binomial distribution, which equals the mean. | |
| dist_binomial_mode() | Returns the mode (most likely value) of the binomial distribution, which equals the mean. | |
| dist_binomial_pdf() | Computes the probability density function (PDF) of the binomial distribution. | |
| dist_binomial_quantile() | Computes the quantile function (inverse CDF) of the binomial distribution. | |
| dist_binomial_quantile_complement() | Computes the complementary quantile function of the binomial distribution. | |
| dist_binomial_range() | Returns the range of the binomial distribution. | |
| dist_binomial_sample() | Generates random samples from the binomial distribution with specified parameters. | |
| dist_binomial_skewness() | Returns the skewness of the binomial distribution. | |
| dist_binomial_support() | Returns the support of the binomial distribution. | |
| dist_binomial_variance() | Returns the variance (σ²) of the binomial distribution. | |
|
Cauchy
Cauchy distribution — heavy-tailed location/scale family with no defined mean. Used in robust statistics and physics. |
||
| dist_cauchy_cdf() | Computes the cumulative distribution function (CDF) of the cauchy distribution. | |
| dist_cauchy_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the cauchy distribution. | |
| dist_cauchy_chf() | Computes the cumulative hazard function of the cauchy distribution. | |
| dist_cauchy_hazard() | Computes the hazard function of the cauchy distribution. | |
| dist_cauchy_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the cauchy distribution. | |
| dist_cauchy_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the cauchy distribution. | |
| dist_cauchy_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the cauchy distribution. | |
| dist_cauchy_median() | Returns the median (50th percentile) of the cauchy distribution, which equals the mean. | |
| dist_cauchy_mode() | Returns the mode (most likely value) of the cauchy distribution, which equals the mean. | |
| dist_cauchy_pdf() | Computes the probability density function (PDF) of the cauchy distribution. | |
| dist_cauchy_quantile() | Computes the quantile function (inverse CDF) of the cauchy distribution. | |
| dist_cauchy_quantile_complement() | Computes the complementary quantile function of the cauchy distribution. | |
| dist_cauchy_range() | Returns the range of the cauchy distribution. | |
| dist_cauchy_sample() | Generates random samples from the cauchy distribution with specified parameters. | |
| dist_cauchy_support() | Returns the support of the cauchy distribution. | |
|
Chi-squared
Chi-squared distribution — sum of k squared standard normals. Used in goodness-of-fit and variance tests. |
||
| dist_chi_squared_cdf() | Computes the cumulative distribution function (CDF) of the chi_squared distribution. | |
| dist_chi_squared_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the chi_squared distribution. | |
| dist_chi_squared_chf() | Computes the cumulative hazard function of the chi_squared distribution. | |
| dist_chi_squared_hazard() | Computes the hazard function of the chi_squared distribution. | |
| dist_chi_squared_kurtosis() | Returns the kurtosis of the chi_squared distribution. | |
| dist_chi_squared_kurtosis_excess() | Returns the excess kurtosis of the chi_squared distribution. | |
| dist_chi_squared_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the chi_squared distribution. | |
| dist_chi_squared_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the chi_squared distribution. | |
| dist_chi_squared_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the chi_squared distribution. | |
| dist_chi_squared_mean() | Returns the mean (μ) of the chi_squared distribution, which is the first moment. | |
| dist_chi_squared_median() | Returns the median (50th percentile) of the chi_squared distribution, which equals the mean. | |
| dist_chi_squared_mode() | Returns the mode (most likely value) of the chi_squared distribution, which equals the mean. | |
| dist_chi_squared_pdf() | Computes the probability density function (PDF) of the chi_squared distribution. | |
| dist_chi_squared_quantile() | Computes the quantile function (inverse CDF) of the chi_squared distribution. | |
| dist_chi_squared_quantile_complement() | Computes the complementary quantile function of the chi_squared distribution. | |
| dist_chi_squared_range() | Returns the range of the chi_squared distribution. | |
| dist_chi_squared_sample() | Generates random samples from the chi_squared distribution with specified parameters. | |
| dist_chi_squared_skewness() | Returns the skewness of the chi_squared distribution. | |
| dist_chi_squared_stddev() | Returns the standard deviation (σ) of the chi_squared distribution. | |
| dist_chi_squared_support() | Returns the support of the chi_squared distribution. | |
| dist_chi_squared_variance() | Returns the variance (σ²) of the chi_squared distribution. | |
|
Exponential
Exponential distribution — memoryless waiting time between events at rate λ. Survival analysis and reliability. |
||
| dist_exponential_cdf() | Computes the cumulative distribution function (CDF) of the exponential distribution. | |
| dist_exponential_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the exponential distribution. | |
| dist_exponential_chf() | Computes the cumulative hazard function of the exponential distribution. | |
| dist_exponential_hazard() | Computes the hazard function of the exponential distribution. | |
| dist_exponential_kurtosis() | Returns the kurtosis of the exponential distribution. | |
| dist_exponential_kurtosis_excess() | Returns the excess kurtosis of the exponential distribution. | |
| dist_exponential_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the exponential distribution. | |
| dist_exponential_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the exponential distribution. | |
| dist_exponential_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the exponential distribution. | |
| dist_exponential_mean() | Returns the mean (μ) of the exponential distribution, which is the first moment. | |
| dist_exponential_median() | Returns the median (50th percentile) of the exponential distribution, which equals the mean. | |
| dist_exponential_mode() | Returns the mode (most likely value) of the exponential distribution, which equals the mean. | |
| dist_exponential_pdf() | Computes the probability density function (PDF) of the exponential distribution. | |
| dist_exponential_quantile() | Computes the quantile function (inverse CDF) of the exponential distribution. | |
| dist_exponential_quantile_complement() | Computes the complementary quantile function of the exponential distribution. | |
| dist_exponential_range() | Returns the range of the exponential distribution. | |
| dist_exponential_sample() | Generates random samples from the exponential distribution with specified parameters. | |
| dist_exponential_skewness() | Returns the skewness of the exponential distribution. | |
| dist_exponential_stddev() | Returns the standard deviation (σ) of the exponential distribution. | |
| dist_exponential_support() | Returns the support of the exponential distribution. | |
| dist_exponential_variance() | Returns the variance (σ²) of the exponential distribution. | |
|
Extreme Value
Generalized extreme-value (Gumbel) — block-maxima of i.i.d. samples. Used in hydrology, insurance, climate. |
||
| dist_extreme_value_cdf() | Computes the cumulative distribution function (CDF) of the extreme_value distribution. | |
| dist_extreme_value_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the extreme_value distribution. | |
| dist_extreme_value_chf() | Computes the cumulative hazard function of the extreme_value distribution. | |
| dist_extreme_value_hazard() | Computes the hazard function of the extreme_value distribution. | |
| dist_extreme_value_kurtosis() | Returns the kurtosis of the extreme_value distribution. | |
| dist_extreme_value_kurtosis_excess() | Returns the excess kurtosis of the extreme_value distribution. | |
| dist_extreme_value_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the extreme_value distribution. | |
| dist_extreme_value_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the extreme_value distribution. | |
| dist_extreme_value_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the extreme_value distribution. | |
| dist_extreme_value_median() | Returns the median (50th percentile) of the extreme_value distribution, which equals the mean. | |
| dist_extreme_value_mode() | Returns the mode (most likely value) of the extreme_value distribution, which equals the mean. | |
| dist_extreme_value_pdf() | Computes the probability density function (PDF) of the extreme_value distribution. | |
| dist_extreme_value_quantile() | Computes the quantile function (inverse CDF) of the extreme_value distribution. | |
| dist_extreme_value_quantile_complement() | Computes the complementary quantile function of the extreme_value distribution. | |
| dist_extreme_value_range() | Returns the range of the extreme_value distribution. | |
| dist_extreme_value_sample() | Generates random samples from the extreme_value distribution with specified parameters. | |
| dist_extreme_value_skewness() | Returns the skewness of the extreme_value distribution. | |
| dist_extreme_value_support() | Returns the support of the extreme_value distribution. | |
| dist_extreme_value_variance() | Returns the variance (σ²) of the extreme_value distribution. | |
|
Fisher F
F distribution — ratio of two scaled chi-squared variates. Backbone of ANOVA and regression hypothesis tests. |
||
| dist_fisher_f_cdf() | Computes the cumulative distribution function (CDF) of the fisher_f distribution. | |
| dist_fisher_f_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the fisher_f distribution. | |
| dist_fisher_f_chf() | Computes the cumulative hazard function of the fisher_f distribution. | |
| dist_fisher_f_hazard() | Computes the hazard function of the fisher_f distribution. | |
| dist_fisher_f_kurtosis() | Returns the kurtosis of the fisher_f distribution. | |
| dist_fisher_f_kurtosis_excess() | Returns the excess kurtosis of the fisher_f distribution. | |
| dist_fisher_f_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the fisher_f distribution. | |
| dist_fisher_f_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the fisher_f distribution. | |
| dist_fisher_f_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the fisher_f distribution. | |
| dist_fisher_f_median() | Returns the median (50th percentile) of the fisher_f distribution, which equals the mean. | |
| dist_fisher_f_mode() | Returns the mode (most likely value) of the fisher_f distribution, which equals the mean. | |
| dist_fisher_f_pdf() | Computes the probability density function (PDF) of the fisher_f distribution. | |
| dist_fisher_f_quantile() | Computes the quantile function (inverse CDF) of the fisher_f distribution. | |
| dist_fisher_f_quantile_complement() | Computes the complementary quantile function of the fisher_f distribution. | |
| dist_fisher_f_range() | Returns the range of the fisher_f distribution. | |
| dist_fisher_f_sample() | Generates random samples from the fisher_f distribution with specified parameters. | |
| dist_fisher_f_skewness() | Returns the skewness of the fisher_f distribution. | |
| dist_fisher_f_support() | Returns the support of the fisher_f distribution. | |
| dist_fisher_f_variance() | Returns the variance (σ²) of the fisher_f distribution. | |
|
Gamma
Gamma distribution — shape/scale family. Waiting times for k events at constant rate; flexible right-skewed prior. |
||
| dist_gamma_cdf() | Computes the cumulative distribution function (CDF) of the gamma distribution. | |
| dist_gamma_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the gamma distribution. | |
| dist_gamma_chf() | Computes the cumulative hazard function of the gamma distribution. | |
| dist_gamma_hazard() | Computes the hazard function of the gamma distribution. | |
| dist_gamma_kurtosis() | Returns the kurtosis of the gamma distribution. | |
| dist_gamma_kurtosis_excess() | Returns the excess kurtosis of the gamma distribution. | |
| dist_gamma_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the gamma distribution. | |
| dist_gamma_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the gamma distribution. | |
| dist_gamma_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the gamma distribution. | |
| dist_gamma_mean() | Returns the mean (μ) of the gamma distribution, which is the first moment. | |
| dist_gamma_median() | Returns the median (50th percentile) of the gamma distribution, which equals the mean. | |
| dist_gamma_mode() | Returns the mode (most likely value) of the gamma distribution, which equals the mean. | |
| dist_gamma_pdf() | Computes the probability density function (PDF) of the gamma distribution. | |
| dist_gamma_quantile() | Computes the quantile function (inverse CDF) of the gamma distribution. | |
| dist_gamma_quantile_complement() | Computes the complementary quantile function of the gamma distribution. | |
| dist_gamma_range() | Returns the range of the gamma distribution. | |
| dist_gamma_sample() | Generates random samples from the gamma distribution with specified parameters. | |
| dist_gamma_skewness() | Returns the skewness of the gamma distribution. | |
| dist_gamma_stddev() | Returns the standard deviation (σ) of the gamma distribution. | |
| dist_gamma_support() | Returns the support of the gamma distribution. | |
| dist_gamma_variance() | Returns the variance (σ²) of the gamma distribution. | |
|
Geometric
Geometric — number of failures before the first success in a Bernoulli trial sequence. |
||
| dist_geometric_cdf() | Computes the cumulative distribution function (CDF) of the geometric distribution. | |
| dist_geometric_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the geometric distribution. | |
| dist_geometric_chf() | Computes the cumulative hazard function of the geometric distribution. | |
| dist_geometric_hazard() | Computes the hazard function of the geometric distribution. | |
| dist_geometric_kurtosis() | Returns the kurtosis of the geometric distribution. | |
| dist_geometric_kurtosis_excess() | Returns the excess kurtosis of the geometric distribution. | |
| dist_geometric_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the geometric distribution. | |
| dist_geometric_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the geometric distribution. | |
| dist_geometric_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the geometric distribution. | |
| dist_geometric_mean() | Returns the mean (μ) of the geometric distribution, which is the first moment. | |
| dist_geometric_median() | Returns the median (50th percentile) of the geometric distribution, which equals the mean. | |
| dist_geometric_mode() | Returns the mode (most likely value) of the geometric distribution, which equals the mean. | |
| dist_geometric_pdf() | Computes the probability density function (PDF) of the geometric distribution. | |
| dist_geometric_quantile() | Computes the quantile function (inverse CDF) of the geometric distribution. | |
| dist_geometric_quantile_complement() | Computes the complementary quantile function of the geometric distribution. | |
| dist_geometric_range() | Returns the range of the geometric distribution. | |
| dist_geometric_sample() | Generates random samples from the geometric distribution with specified parameters. | |
| dist_geometric_skewness() | Returns the skewness of the geometric distribution. | |
| dist_geometric_stddev() | Returns the standard deviation (σ) of the geometric distribution. | |
| dist_geometric_support() | Returns the support of the geometric distribution. | |
| dist_geometric_variance() | Returns the variance (σ²) of the geometric distribution. | |
|
Laplace
Laplace (double exponential) — location/scale. Heavier tails than Normal; used in regularized regression and noise modeling. |
||
| dist_laplace_cdf() | Computes the cumulative distribution function (CDF) of the laplace distribution. | |
| dist_laplace_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the laplace distribution. | |
| dist_laplace_chf() | Computes the cumulative hazard function of the laplace distribution. | |
| dist_laplace_hazard() | Computes the hazard function of the laplace distribution. | |
| dist_laplace_kurtosis() | Returns the kurtosis of the laplace distribution. | |
| dist_laplace_kurtosis_excess() | Returns the excess kurtosis of the laplace distribution. | |
| dist_laplace_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the laplace distribution. | |
| dist_laplace_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the laplace distribution. | |
| dist_laplace_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the laplace distribution. | |
| dist_laplace_mean() | Returns the mean (μ) of the laplace distribution, which is the first moment. | |
| dist_laplace_median() | Returns the median (50th percentile) of the laplace distribution, which equals the mean. | |
| dist_laplace_mode() | Returns the mode (most likely value) of the laplace distribution, which equals the mean. | |
| dist_laplace_pdf() | Computes the probability density function (PDF) of the laplace distribution. | |
| dist_laplace_quantile() | Computes the quantile function (inverse CDF) of the laplace distribution. | |
| dist_laplace_quantile_complement() | Computes the complementary quantile function of the laplace distribution. | |
| dist_laplace_range() | Returns the range of the laplace distribution. | |
| dist_laplace_sample() | Generates random samples from the laplace distribution with specified parameters. | |
| dist_laplace_skewness() | Returns the skewness of the laplace distribution. | |
| dist_laplace_stddev() | Returns the standard deviation (σ) of the laplace distribution. | |
| dist_laplace_support() | Returns the support of the laplace distribution. | |
| dist_laplace_variance() | Returns the variance (σ²) of the laplace distribution. | |
|
Log-normal
Log-normal — exp of a Normal. Models multiplicative growth, income, lifetimes; right-skewed with heavy tail. |
||
| dist_lognormal_cdf() | Computes the cumulative distribution function (CDF) of the lognormal distribution. | |
| dist_lognormal_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the lognormal distribution. | |
| dist_lognormal_chf() | Computes the cumulative hazard function of the lognormal distribution. | |
| dist_lognormal_hazard() | Computes the hazard function of the lognormal distribution. | |
| dist_lognormal_kurtosis() | Returns the kurtosis of the lognormal distribution. | |
| dist_lognormal_kurtosis_excess() | Returns the excess kurtosis of the lognormal distribution. | |
| dist_lognormal_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the lognormal distribution. | |
| dist_lognormal_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the lognormal distribution. | |
| dist_lognormal_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the lognormal distribution. | |
| dist_lognormal_mean() | Returns the mean (μ) of the lognormal distribution, which is the first moment. | |
| dist_lognormal_median() | Returns the median (50th percentile) of the lognormal distribution, which equals the mean. | |
| dist_lognormal_mode() | Returns the mode (most likely value) of the lognormal distribution, which equals the mean. | |
| dist_lognormal_pdf() | Computes the probability density function (PDF) of the lognormal distribution. | |
| dist_lognormal_quantile() | Computes the quantile function (inverse CDF) of the lognormal distribution. | |
| dist_lognormal_quantile_complement() | Computes the complementary quantile function of the lognormal distribution. | |
| dist_lognormal_range() | Returns the range of the lognormal distribution. | |
| dist_lognormal_sample() | Generates random samples from the lognormal distribution with specified parameters. | |
| dist_lognormal_skewness() | Returns the skewness of the lognormal distribution. | |
| dist_lognormal_stddev() | Returns the standard deviation (σ) of the lognormal distribution. | |
| dist_lognormal_support() | Returns the support of the lognormal distribution. | |
| dist_lognormal_variance() | Returns the variance (σ²) of the lognormal distribution. | |
|
Logistic
Logistic distribution — symmetric S-curve via location/scale. Backbone of logistic regression and Elo-style ratings. |
||
| dist_logistic_cdf() | Computes the cumulative distribution function (CDF) of the logistic distribution. | |
| dist_logistic_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the logistic distribution. | |
| dist_logistic_chf() | Computes the cumulative hazard function of the logistic distribution. | |
| dist_logistic_hazard() | Computes the hazard function of the logistic distribution. | |
| dist_logistic_kurtosis() | Returns the kurtosis of the logistic distribution. | |
| dist_logistic_kurtosis_excess() | Returns the excess kurtosis of the logistic distribution. | |
| dist_logistic_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the logistic distribution. | |
| dist_logistic_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the logistic distribution. | |
| dist_logistic_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the logistic distribution. | |
| dist_logistic_median() | Returns the median (50th percentile) of the logistic distribution, which equals the mean. | |
| dist_logistic_mode() | Returns the mode (most likely value) of the logistic distribution, which equals the mean. | |
| dist_logistic_pdf() | Computes the probability density function (PDF) of the logistic distribution. | |
| dist_logistic_quantile() | Computes the quantile function (inverse CDF) of the logistic distribution. | |
| dist_logistic_quantile_complement() | Computes the complementary quantile function of the logistic distribution. | |
| dist_logistic_range() | Returns the range of the logistic distribution. | |
| dist_logistic_sample() | Generates random samples from the logistic distribution with specified parameters. | |
| dist_logistic_skewness() | Returns the skewness of the logistic distribution. | |
| dist_logistic_support() | Returns the support of the logistic distribution. | |
| dist_logistic_variance() | Returns the variance (σ²) of the logistic distribution. | |
|
Negative Binomial
Negative Binomial — number of failures before r successes. Used for over-dispersed count data. |
||
| dist_negative_binomial_cdf() | Computes the cumulative distribution function (CDF) of the negative_binomial distribution. | |
| dist_negative_binomial_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the negative_binomial distribution. | |
| dist_negative_binomial_chf() | Computes the cumulative hazard function of the negative_binomial distribution. | |
| dist_negative_binomial_hazard() | Computes the hazard function of the negative_binomial distribution. | |
| dist_negative_binomial_kurtosis() | Returns the kurtosis of the negative_binomial distribution. | |
| dist_negative_binomial_kurtosis_excess() | Returns the excess kurtosis of the negative_binomial distribution. | |
| dist_negative_binomial_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the negative_binomial distribution. | |
| dist_negative_binomial_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the negative_binomial distribution. | |
| dist_negative_binomial_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the negative_binomial distribution. | |
| dist_negative_binomial_median() | Returns the median (50th percentile) of the negative_binomial distribution, which equals the mean. | |
| dist_negative_binomial_mode() | Returns the mode (most likely value) of the negative_binomial distribution, which equals the mean. | |
| dist_negative_binomial_pdf() | Computes the probability density function (PDF) of the negative_binomial distribution. | |
| dist_negative_binomial_quantile() | Computes the quantile function (inverse CDF) of the negative_binomial distribution. | |
| dist_negative_binomial_quantile_complement() | Computes the complementary quantile function of the negative_binomial distribution. | |
| dist_negative_binomial_range() | Returns the range of the negative_binomial distribution. | |
| dist_negative_binomial_sample() | Generates random samples from the negative_binomial distribution with specified parameters. | |
| dist_negative_binomial_skewness() | Returns the skewness of the negative_binomial distribution. | |
| dist_negative_binomial_support() | Returns the support of the negative_binomial distribution. | |
| dist_negative_binomial_variance() | Returns the variance (σ²) of the negative_binomial distribution. | |
|
Normal
Normal (Gaussian) — the workhorse continuous distribution. Z-scores, confidence intervals, central limit applications. |
||
| dist_normal_cdf() | Computes the cumulative distribution function (CDF) of the normal distribution. | |
| dist_normal_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the normal distribution. | |
| dist_normal_chf() | Computes the cumulative hazard function of the normal distribution. | |
| dist_normal_hazard() | Computes the hazard function of the normal distribution. | |
| dist_normal_kurtosis() | Returns the kurtosis of the normal distribution. | |
| dist_normal_kurtosis_excess() | Returns the excess kurtosis of the normal distribution. | |
| dist_normal_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the normal distribution. | |
| dist_normal_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the normal distribution. | |
| dist_normal_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the normal distribution. | |
| dist_normal_mean() | Returns the mean (μ) of the normal distribution, which is the first moment. | |
| dist_normal_median() | Returns the median (50th percentile) of the normal distribution, which equals the mean. | |
| dist_normal_mode() | Returns the mode (most likely value) of the normal distribution, which equals the mean. | |
| dist_normal_pdf() | Computes the probability density function (PDF) of the normal distribution. | |
| dist_normal_quantile() | Computes the quantile function (inverse CDF) of the normal distribution. | |
| dist_normal_quantile_complement() | Computes the complementary quantile function of the normal distribution. | |
| dist_normal_range() | Returns the range of the normal distribution. | |
| dist_normal_sample() | Generates random samples from the normal distribution with specified parameters. | |
| dist_normal_skewness() | Returns the skewness of the normal distribution. | |
| dist_normal_stddev() | Returns the standard deviation (σ) of the normal distribution. | |
| dist_normal_support() | Returns the support of the normal distribution. | |
| dist_normal_variance() | Returns the variance (σ²) of the normal distribution. | |
|
Pareto
Pareto distribution — power-law tail with scale and shape. Wealth, file sizes, internet traffic; the 80/20 rule. |
||
| dist_pareto_cdf() | Computes the cumulative distribution function (CDF) of the pareto distribution. | |
| dist_pareto_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the pareto distribution. | |
| dist_pareto_chf() | Computes the cumulative hazard function of the pareto distribution. | |
| dist_pareto_hazard() | Computes the hazard function of the pareto distribution. | |
| dist_pareto_kurtosis() | Returns the kurtosis of the pareto distribution. | |
| dist_pareto_kurtosis_excess() | Returns the excess kurtosis of the pareto distribution. | |
| dist_pareto_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the pareto distribution. | |
| dist_pareto_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the pareto distribution. | |
| dist_pareto_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the pareto distribution. | |
| dist_pareto_mean() | Returns the mean (μ) of the pareto distribution, which is the first moment. | |
| dist_pareto_median() | Returns the median (50th percentile) of the pareto distribution, which equals the mean. | |
| dist_pareto_mode() | Returns the mode (most likely value) of the pareto distribution, which equals the mean. | |
| dist_pareto_pdf() | Computes the probability density function (PDF) of the pareto distribution. | |
| dist_pareto_quantile() | Computes the quantile function (inverse CDF) of the pareto distribution. | |
| dist_pareto_quantile_complement() | Computes the complementary quantile function of the pareto distribution. | |
| dist_pareto_range() | Returns the range of the pareto distribution. | |
| dist_pareto_sample() | Generates random samples from the pareto distribution with specified parameters. | |
| dist_pareto_skewness() | Returns the skewness of the pareto distribution. | |
| dist_pareto_stddev() | Returns the standard deviation (σ) of the pareto distribution. | |
| dist_pareto_support() | Returns the support of the pareto distribution. | |
| dist_pareto_variance() | Returns the variance (σ²) of the pareto distribution. | |
|
Poisson
Poisson — count of independent events in fixed interval at rate λ. Arrivals, defects, rare-event counts. |
||
| dist_poisson_cdf() | Computes the cumulative distribution function (CDF) of the poisson distribution. | |
| dist_poisson_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the poisson distribution. | |
| dist_poisson_chf() | Computes the cumulative hazard function of the poisson distribution. | |
| dist_poisson_hazard() | Computes the hazard function of the poisson distribution. | |
| dist_poisson_kurtosis() | Returns the kurtosis of the poisson distribution. | |
| dist_poisson_kurtosis_excess() | Returns the excess kurtosis of the poisson distribution. | |
| dist_poisson_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the poisson distribution. | |
| dist_poisson_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the poisson distribution. | |
| dist_poisson_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the poisson distribution. | |
| dist_poisson_mean() | Returns the mean (μ) of the poisson distribution, which is the first moment. | |
| dist_poisson_median() | Returns the median (50th percentile) of the poisson distribution, which equals the mean. | |
| dist_poisson_mode() | Returns the mode (most likely value) of the poisson distribution, which equals the mean. | |
| dist_poisson_pdf() | Computes the probability density function (PDF) of the poisson distribution. | |
| dist_poisson_quantile() | Computes the quantile function (inverse CDF) of the poisson distribution. | |
| dist_poisson_quantile_complement() | Computes the complementary quantile function of the poisson distribution. | |
| dist_poisson_range() | Returns the range of the poisson distribution. | |
| dist_poisson_sample() | Generates random samples from the poisson distribution with specified parameters. | |
| dist_poisson_skewness() | Returns the skewness of the poisson distribution. | |
| dist_poisson_stddev() | Returns the standard deviation (σ) of the poisson distribution. | |
| dist_poisson_support() | Returns the support of the poisson distribution. | |
| dist_poisson_variance() | Returns the variance (σ²) of the poisson distribution. | |
|
Rayleigh
Rayleigh distribution — magnitude of a 2D vector with i.i.d. Normal components. Wind speed, signal envelopes. |
||
| dist_rayleigh_cdf() | Computes the cumulative distribution function (CDF) of the rayleigh distribution. | |
| dist_rayleigh_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the rayleigh distribution. | |
| dist_rayleigh_chf() | Computes the cumulative hazard function of the rayleigh distribution. | |
| dist_rayleigh_hazard() | Computes the hazard function of the rayleigh distribution. | |
| dist_rayleigh_kurtosis() | Returns the kurtosis of the rayleigh distribution. | |
| dist_rayleigh_kurtosis_excess() | Returns the excess kurtosis of the rayleigh distribution. | |
| dist_rayleigh_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the rayleigh distribution. | |
| dist_rayleigh_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the rayleigh distribution. | |
| dist_rayleigh_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the rayleigh distribution. | |
| dist_rayleigh_mean() | Returns the mean (μ) of the rayleigh distribution, which is the first moment. | |
| dist_rayleigh_median() | Returns the median (50th percentile) of the rayleigh distribution, which equals the mean. | |
| dist_rayleigh_mode() | Returns the mode (most likely value) of the rayleigh distribution, which equals the mean. | |
| dist_rayleigh_pdf() | Computes the probability density function (PDF) of the rayleigh distribution. | |
| dist_rayleigh_quantile() | Computes the quantile function (inverse CDF) of the rayleigh distribution. | |
| dist_rayleigh_quantile_complement() | Computes the complementary quantile function of the rayleigh distribution. | |
| dist_rayleigh_range() | Returns the range of the rayleigh distribution. | |
| dist_rayleigh_sample() | Generates random samples from the rayleigh distribution with specified parameters. | |
| dist_rayleigh_skewness() | Returns the skewness of the rayleigh distribution. | |
| dist_rayleigh_stddev() | Returns the standard deviation (σ) of the rayleigh distribution. | |
| dist_rayleigh_support() | Returns the support of the rayleigh distribution. | |
| dist_rayleigh_variance() | Returns the variance (σ²) of the rayleigh distribution. | |
|
Student's t
Student's t — heavier-tailed alternative to Normal, parameterized by degrees of freedom. Small-sample inference. |
||
| dist_students_t_cdf() | Computes the cumulative distribution function (CDF) of the students_t distribution. | |
| dist_students_t_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the students_t distribution. | |
| dist_students_t_chf() | Computes the cumulative hazard function of the students_t distribution. | |
| dist_students_t_hazard() | Computes the hazard function of the students_t distribution. | |
| dist_students_t_kurtosis() | Returns the kurtosis of the students_t distribution. | |
| dist_students_t_kurtosis_excess() | Returns the excess kurtosis of the students_t distribution. | |
| dist_students_t_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the students_t distribution. | |
| dist_students_t_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the students_t distribution. | |
| dist_students_t_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the students_t distribution. | |
| dist_students_t_mean() | Returns the mean (μ) of the students_t distribution, which is the first moment. | |
| dist_students_t_median() | Returns the median (50th percentile) of the students_t distribution, which equals the mean. | |
| dist_students_t_mode() | Returns the mode (most likely value) of the students_t distribution, which equals the mean. | |
| dist_students_t_pdf() | Computes the probability density function (PDF) of the students_t distribution. | |
| dist_students_t_quantile() | Computes the quantile function (inverse CDF) of the students_t distribution. | |
| dist_students_t_quantile_complement() | Computes the complementary quantile function of the students_t distribution. | |
| dist_students_t_range() | Returns the range of the students_t distribution. | |
| dist_students_t_sample() | Generates random samples from the students_t distribution with specified parameters. | |
| dist_students_t_skewness() | Returns the skewness of the students_t distribution. | |
| dist_students_t_stddev() | Returns the standard deviation (σ) of the students_t distribution. | |
| dist_students_t_support() | Returns the support of the students_t distribution. | |
| dist_students_t_variance() | Returns the variance (σ²) of the students_t distribution. | |
|
Uniform (Integer)
Discrete uniform — every integer in [min, max] equally likely. Random index sampling, dice rolls. |
||
| dist_uniform_int_cdf() | Computes the cumulative distribution function (CDF) of the uniform_int distribution. | |
| dist_uniform_int_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the uniform_int distribution. | |
| dist_uniform_int_chf() | Computes the cumulative hazard function of the uniform_int distribution. | |
| dist_uniform_int_hazard() | Computes the hazard function of the uniform_int distribution. | |
| dist_uniform_int_kurtosis() | Returns the kurtosis of the uniform_int distribution. | |
| dist_uniform_int_kurtosis_excess() | Returns the excess kurtosis of the uniform_int distribution. | |
| dist_uniform_int_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the uniform_int distribution. | |
| dist_uniform_int_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the uniform_int distribution. | |
| dist_uniform_int_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the uniform_int distribution. | |
| dist_uniform_int_mean() | Returns the mean (μ) of the uniform_int distribution, which is the first moment. | |
| dist_uniform_int_median() | Returns the median (50th percentile) of the uniform_int distribution, which equals the mean. | |
| dist_uniform_int_mode() | Returns the mode (most likely value) of the uniform_int distribution, which equals the mean. | |
| dist_uniform_int_pdf() | Computes the probability density function (PDF) of the uniform_int distribution. | |
| dist_uniform_int_quantile() | Computes the quantile function (inverse CDF) of the uniform_int distribution. | |
| dist_uniform_int_quantile_complement() | Computes the complementary quantile function of the uniform_int distribution. | |
| dist_uniform_int_range() | Returns the range of the uniform_int distribution. | |
| dist_uniform_int_sample() | Generates random samples from the uniform_int distribution with specified parameters. | |
| dist_uniform_int_skewness() | Returns the skewness of the uniform_int distribution. | |
| dist_uniform_int_stddev() | Returns the standard deviation (σ) of the uniform_int distribution. | |
| dist_uniform_int_support() | Returns the support of the uniform_int distribution. | |
| dist_uniform_int_variance() | Returns the variance (σ²) of the uniform_int distribution. | |
|
Uniform (Real)
Continuous uniform on [min, max]. The default sampling distribution and a building block for inverse-transform sampling. |
||
| dist_uniform_real_cdf() | Computes the cumulative distribution function (CDF) of the uniform_real distribution. | |
| dist_uniform_real_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the uniform_real distribution. | |
| dist_uniform_real_chf() | Computes the cumulative hazard function of the uniform_real distribution. | |
| dist_uniform_real_hazard() | Computes the hazard function of the uniform_real distribution. | |
| dist_uniform_real_kurtosis() | Returns the kurtosis of the uniform_real distribution. | |
| dist_uniform_real_kurtosis_excess() | Returns the excess kurtosis of the uniform_real distribution. | |
| dist_uniform_real_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the uniform_real distribution. | |
| dist_uniform_real_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the uniform_real distribution. | |
| dist_uniform_real_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the uniform_real distribution. | |
| dist_uniform_real_mean() | Returns the mean (μ) of the uniform_real distribution, which is the first moment. | |
| dist_uniform_real_median() | Returns the median (50th percentile) of the uniform_real distribution, which equals the mean. | |
| dist_uniform_real_mode() | Returns the mode (most likely value) of the uniform_real distribution, which equals the mean. | |
| dist_uniform_real_pdf() | Computes the probability density function (PDF) of the uniform_real distribution. | |
| dist_uniform_real_quantile() | Computes the quantile function (inverse CDF) of the uniform_real distribution. | |
| dist_uniform_real_quantile_complement() | Computes the complementary quantile function of the uniform_real distribution. | |
| dist_uniform_real_range() | Returns the range of the uniform_real distribution. | |
| dist_uniform_real_sample() | Generates random samples from the uniform_real distribution with specified parameters. | |
| dist_uniform_real_skewness() | Returns the skewness of the uniform_real distribution. | |
| dist_uniform_real_stddev() | Returns the standard deviation (σ) of the uniform_real distribution. | |
| dist_uniform_real_support() | Returns the support of the uniform_real distribution. | |
| dist_uniform_real_variance() | Returns the variance (σ²) of the uniform_real distribution. | |
|
Weibull
Weibull distribution — flexible shape/scale. Reliability engineering, time-to-failure, wind-speed modeling. |
||
| dist_weibull_cdf() | Computes the cumulative distribution function (CDF) of the weibull distribution. | |
| dist_weibull_cdf_complement() | Computes the complementary cumulative distribution function (1 - CDF) of the weibull distribution. | |
| dist_weibull_chf() | Computes the cumulative hazard function of the weibull distribution. | |
| dist_weibull_hazard() | Computes the hazard function of the weibull distribution. | |
| dist_weibull_kurtosis() | Returns the kurtosis of the weibull distribution. | |
| dist_weibull_kurtosis_excess() | Returns the excess kurtosis of the weibull distribution. | |
| dist_weibull_log_cdf() | Computes the natural logarithm of the cumulative distribution function (CDF) of the weibull distribution. | |
| dist_weibull_log_cdf_complement() | Computes the natural logarithm of the complementary cumulative distribution function (1 - CDF) of the weibull distribution. | |
| dist_weibull_log_pdf() | Computes the natural logarithm of the probability density function (log-PDF) of the weibull distribution. | |
| dist_weibull_median() | Returns the median (50th percentile) of the weibull distribution, which equals the mean. | |
| dist_weibull_mode() | Returns the mode (most likely value) of the weibull distribution, which equals the mean. | |
| dist_weibull_pdf() | Computes the probability density function (PDF) of the weibull distribution. | |
| dist_weibull_quantile() | Computes the quantile function (inverse CDF) of the weibull distribution. | |
| dist_weibull_quantile_complement() | Computes the complementary quantile function of the weibull distribution. | |
| dist_weibull_range() | Returns the range of the weibull distribution. | |
| dist_weibull_sample() | Generates random samples from the weibull distribution with specified parameters. | |
| dist_weibull_skewness() | Returns the skewness of the weibull distribution. | |
| dist_weibull_support() | Returns the support of the weibull distribution. | |
| dist_weibull_variance() | Returns the variance (σ²) of the weibull distribution. | |
No extension contents match that search.
API Reference
Function Documentation
Practical Examples
Cookbook
Real-world recipes and patterns for common use cases.
Recipes are organized by distribution family. Every distribution exposes the same operations — sample, pdf / log_pdf, cdf / log_cdf / cdf_complement, quantile, plus property functions (mean, variance, skewness, …). Once you’ve used one family, the rest follow the same shape.
Normal — the workhorse
Z-scores, confidence intervals, two-sided p-values, VaR. The Normal distribution is parameterized by mean and standard deviation:
-- Quantiles, density, CDFSELECT dist_normal_quantile(0.0, 1.0, 0.95) AS p95; -- 1.6449SELECT dist_normal_pdf(0.0, 1.0, 0.5) AS density;SELECT dist_normal_cdf(0.0, 1.0, 1.96) AS prob; -- ~0.975-- Z-score using property functions inlineSELECT height_cm, (height_cm - dist_normal_mean(100, 15)) / dist_normal_stddev(100, 15) AS height_zscoreFROM observations;-- Two-sided p-value from a Z-statisticWITH z AS (SELECT 2.31 AS stat)SELECT 2 * dist_normal_cdf_complement(0.0, 1.0, ABS(stat)) AS p_valueFROM z;See dist_normal_pdf, dist_normal_cdf, dist_normal_quantile, dist_normal_sample.
Discrete counts — Binomial and Poisson
Binomial for fixed-trial successes; Poisson for events at a rate:
-- Binomial: P(X = 7), P(X ≤ 5), random kSELECT dist_binomial_pdf(10, 0.3, 7) AS prob_exactly_7;SELECT dist_binomial_cdf(10, 0.3, 5) AS prob_at_most_5;SELECT dist_binomial_sample(10, 0.3) AS k;-- Poisson: probability of seeing >= 5 arrivals when λ=2.5SELECT dist_poisson_cdf_complement(2.5, 4) AS prob_5_or_more;-- Poisson sample for synthetic event-count columnsSELECT i, dist_poisson_sample(2.5) AS arrivalsFROM range(10) t(i);See dist_binomial_pdf, dist_binomial_cdf, dist_poisson_cdf, dist_poisson_sample.
Time-to-event — Exponential, Weibull, Gamma
Exponential for memoryless waiting times; Weibull for time-to-failure with non-constant hazard; Gamma for waiting times across multiple events:
-- Survival probability past t=2 for Exponential(rate=0.5)SELECT dist_exponential_cdf_complement(0.5, 2.0) AS surviving;-- Hazard rate at t=10 for Weibull(shape=1.5, scale=8)SELECT dist_weibull_hazard(1.5, 8.0, 10.0) AS instantaneous_hazard;-- Sample 1,000 service times from Gamma(2, 3)SELECT dist_gamma_sample(2.0, 3.0) AS service_secsFROM range(1000);See dist_exponential_cdf_complement, dist_weibull_hazard, dist_gamma_sample.
Bayesian conjugates — Beta and Gamma priors
Closed-form conjugate posteriors are one quantile call away. After observing 17 successes in 25 trials with a Beta(2, 2) prior, the posterior is Beta(19, 10):
-- Posterior mean and 95% credible intervalSELECT dist_beta_mean(19, 10) AS posterior_mean, dist_beta_quantile(19, 10, 0.025) AS ci_lo, dist_beta_quantile(19, 10, 0.975) AS ci_hi;See dist_beta_mean, dist_beta_quantile.
Hypothesis testing — t, chi-squared, F
-- Two-sided t-test p-value, df=29WITH t AS (SELECT 2.045 AS stat, 29 AS df)SELECT 2 * dist_students_t_cdf_complement(df, ABS(stat)) AS p_valueFROM t;-- Chi-squared goodness-of-fit p-value, df=4WITH chi AS (SELECT 9.488 AS stat)SELECT dist_chi_squared_cdf_complement(4, stat) AS p_valueFROM chi;-- F-test (ANOVA) p-value, df1=3 df2=20WITH f AS (SELECT 4.94 AS stat)SELECT dist_fisher_f_cdf_complement(3, 20, stat) AS p_valueFROM f;See dist_students_t_cdf_complement, dist_chi_squared_cdf_complement, dist_fisher_f_cdf_complement.
Heavy-tailed families — Pareto, Cauchy, Log-normal
Wealth, file sizes, internet traffic, financial returns. The tail dominates; reach for these when the Normal underestimates extremes:
-- Probability a file exceeds 1 GB under Pareto(scale=10MB, shape=1.5)SELECT dist_pareto_cdf_complement(10.0, 1.5, 1024.0) AS prob_over_1gb;-- Median income under Log-normal(meanlog=10.5, sdlog=0.7)SELECT dist_lognormal_median(10.5, 0.7) AS median_income;See dist_pareto_cdf_complement, dist_lognormal_median.
Synthetic data — combine families per column
Sampling functions return one draw per call, so combine them with range() over any source row count:
CREATE TABLE synthetic_users ASSELECT i AS user_id, dist_normal_sample(170, 8) AS height_cm, dist_lognormal_sample(10.5, 0.7) AS annual_income, dist_poisson_sample(3.5) AS sessions_last_week, dist_exponential_sample(0.1) AS avg_session_minutes, dist_bernoulli_sample(0.12) AS convertedFROM range(100000) t(i);One query, 100k rows of realistic-looking fixture data — heights from a Normal, incomes from a Log-normal, session counts from a Poisson, conversions from a Bernoulli.
Monte Carlo — the canonical example
-- Estimate π by sampling uniform points in [-1,1]² and counting hits inside the unit circleWITH samples AS ( SELECT dist_uniform_real_sample(-1.0, 1.0) AS x, dist_uniform_real_sample(-1.0, 1.0) AS y FROM range(1000000))SELECT 4.0 * COUNT(*) FILTER (WHERE x*x + y*y <= 1) / COUNT(*) AS pi_estimateFROM samples;The same pattern — generate, filter, aggregate — handles VaR, payoff integration, queueing simulation, A/B-test power calculations.
Value at Risk
-- 1-day 99% VaR assuming Normal returnsWITH params AS (SELECT 0.0001 AS mu, 0.02 AS sigma, 1000000 AS portfolio)SELECT portfolio * (-dist_normal_quantile(mu, sigma, 0.01)) AS var_99FROM params;For heavy-tailed VaR, swap dist_normal_quantile for dist_students_t_quantile with a low df.
Log-scale variants for likelihoods
Every PDF / CDF / CDF-complement has a _log_* variant. Use them inside likelihood computations and to avoid underflow on tiny tails:
-- Log-likelihood of one observation under N(0,1)SELECT dist_normal_log_pdf(0.0, 1.0, 4.5) AS log_density;-- Log-survival for very small tail probabilitiesSELECT dist_normal_log_cdf_complement(0.0, 1.0, 6.0) AS log_tail;See dist_normal_log_pdf, dist_normal_log_cdf_complement.
Reproducibility
_sample functions don’t take a seed parameter. For exactly-reproducible runs, materialize the draws once into a table and treat that table as the seed:
CREATE TABLE rng_pool ASSELECT i, dist_normal_sample(0, 1) AS zFROM range(1000000) t(i);
-- Subsequent analyses read from rng_pool — fully reproduciblePlatform Support
Compatibility
Extension availability may vary by platform and DuckDB version. Check below to ensure this extension supports your environment before installation.
Quick Facts
Platforms
- Linux x86_64 aarch64
- Linux (musl) Not available
- macOS Intel Apple Silicon
- Windows x86_64
- WASM eh mvp threads
Compiled binary sizes
| Platform | Architecture | Size |
|---|---|---|
| Linux | x86_64 | 4.56 MB |
| Linux | aarch64 | 4.03 MB |
| macOS | Intel | 3.03 MB |
| macOS | Apple Silicon | 2.65 MB |
| Windows | x86_64 | 8.38 MB |
| WASM | eh | 637.4 KB |
| WASM | mvp | 578.9 KB |
| WASM | threads | 637.7 KB |
Compressed download size from the Haybarn extension repository.
DuckDB & Haybarn
Release calendar- DuckDB v1.5.5 Haybarn 1.5.5-rc1 Supported