Normal functions in the Stochastic DuckDB extension
Function category
Normal
24 functionsNormal (Gaussian) — the workhorse continuous distribution. Z-scores, confidence intervals, central limit applications.
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x).
SELECT dist_normal_cdf(0.0, 1.0, 0.5);
Output
| dist_normal_cdf(0.0, 1.0, 0.5) |
|---|
| 0.6914624612740131 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the complementary cumulative distribution function (survival function) of the normal distribution, P(X > x).
SELECT dist_normal_cdf_complement(0.0, 1.0, 0.5);
Output
| dist_normal_cdf_complement(0.0, 1.0, 0.5) |
|---|
| 0.3085375387259869 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the cumulative hazard function of the normal distribution at x.
SELECT dist_normal_chf(0.0, 1.0, 0.5);
Output
| dist_normal_chf(0.0, 1.0, 0.5) |
|---|
| 1.1759117615936188 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a normal distribution to x by maximum likelihood. Returns a STRUCT with the fitted parameters (mean, stddev) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT dist_normal_fit(x) AS fit
FROM (VALUES (2.1), (3.4), (2.9), (4.2), (3.3), (2.6)) t(x);
Output
| fit |
|---|
| {'mean': 3.083333333333333, 'stddev': 0.6618576550554928, 'log_likelihood': -6.037402586784546, 'aic': 16.074805173569093, 'bic': 15.658324112025202} |
Related functions
- dist_normal_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the normal distribution with the given parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the hazard function of the normal distribution at x.
SELECT dist_normal_hazard(0.0, 1.0, 0.5);
Output
| dist_normal_hazard(0.0, 1.0, 0.5) |
|---|
| 1.1410777703680648 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
One-sample Kolmogorov-Smirnov test of whether x follows the normal distribution with the given parameters. Returns the statistic D and the asymptotic p-value.
SELECT dist_normal_ks_test(x, 0.0, 1.0) AS ks
FROM (VALUES (-1.2), (0.3), (0.8), (-0.4), (1.9), (0.1), (-0.7), (0.5)) t(x);
Output
| ks |
|---|
| {'statistic': 0.164827837277029, 'p_value': 0.9815767356290033} |
Related functions
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the kurtosis of the normal distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_normal_kurtosis(0.0, 1.0);
Output
| dist_normal_kurtosis(0.0, 1.0) |
|---|
| 3.0 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the excess kurtosis of the normal distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_normal_kurtosis_excess(0.0, 1.0);
Output
| dist_normal_kurtosis_excess(0.0, 1.0) |
|---|
| 0.0 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the natural logarithm of the cumulative distribution function (CDF) of the normal distribution.
SELECT dist_normal_log_cdf(0.0, 1.0, 0.5);
Output
| dist_normal_log_cdf(0.0, 1.0, 0.5) |
|---|
| -0.36894641528865635 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the natural logarithm of the survival function of the normal distribution, log P(X > x).
SELECT dist_normal_log_cdf_complement(0.0, 1.0, 0.5);
Output
| dist_normal_log_cdf_complement(0.0, 1.0, 0.5) |
|---|
| -1.1759117615936188 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the natural logarithm of the probability density function (PDF) of the normal distribution at x. Useful for numerical stability when dealing with very small probabilities.
SELECT dist_normal_log_pdf(0.0, 1.0, 0.5);
Output
| dist_normal_log_pdf(0.0, 1.0, 0.5) |
|---|
| -1.0439385332046727 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the mean of the normal distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_normal_mean(0.0, 1.0);
Output
| dist_normal_mean(0.0, 1.0) |
|---|
| 0.0 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the median of the normal distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_normal_median(0.0, 1.0);
Output
| dist_normal_median(0.0, 1.0) |
|---|
| 0.0 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the mode (most likely value) of the normal distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_normal_mode(0.0, 1.0);
Output
| dist_normal_mode(0.0, 1.0) |
|---|
| 0.0 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the probability density function (PDF) of the normal distribution at x.
SELECT dist_normal_pdf(0.0, 1.0, 0.5);
Output
| dist_normal_pdf(0.0, 1.0, 0.5) |
|---|
| 0.3520653267642995 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
p
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the quantile function (inverse CDF) of the normal distribution. Returns the smallest x such that P(X <= x) >= p.
SELECT dist_normal_quantile(0.0, 1.0, 0.95);
Output
| dist_normal_quantile(0.0, 1.0, 0.95) |
|---|
| 1.6448536269514729 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
p
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the complementary quantile function of the normal distribution. Returns x such that P(X > x) = p, useful for upper tail quantiles.
SELECT dist_normal_quantile_complement(0.0, 1.0, 0.95);
Output
| dist_normal_quantile_complement(0.0, 1.0, 0.95) |
|---|
| -1.6448536269514729 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the range of the normal distribution as [min, max].
SELECT dist_normal_range(0.0, 1.0);
Output
| dist_normal_range(0.0, 1.0) |
|---|
| [-inf, inf] |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Generates a random sample from the normal distribution with the specified parameters.
SELECT dist_normal_sample(0.0, 1.0);
Output
| dist_normal_sample(0.0, 1.0) |
|---|
| -0.6752094564780856 |
Related functions
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
n
|
Type
BIGINT
|
Mode Positional | Description |
Description
Generates a list of n random samples from the normal distribution with the specified parameters.
SELECT len(dist_normal_samples(0.0, 1.0, 1000)) AS n;
Output
| n |
|---|
| 1000 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the skewness of the normal distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_normal_skewness(0.0, 1.0);
Output
| dist_normal_skewness(0.0, 1.0) |
|---|
| 0.0 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the standard deviation of the normal distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_normal_stddev(0.0, 1.0);
Output
| dist_normal_stddev(0.0, 1.0) |
|---|
| 1.0 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the support of the normal distribution as [min, max].
SELECT dist_normal_support(0.0, 1.0);
Output
| dist_normal_support(0.0, 1.0) |
|---|
| [-inf, inf] |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
mean
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
stddev
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the variance of the normal distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_normal_variance(0.0, 1.0);
Output
| dist_normal_variance(0.0, 1.0) |
|---|
| 1.0 |
Related functions
- dist_normal_sample() — Generates a random sample from the normal distribution with the specified parameters
- dist_normal_pdf() — Computes the probability density function (PDF) of the normal distribution at x
- dist_normal_cdf() — Computes the cumulative distribution function (CDF) of the normal distribution, P(X <= x)
- dist_normal_quantile() — Computes the quantile function (inverse CDF) of the normal distribution
- dist_normal_mean() — Returns the mean of the normal distribution
- dist_normal_stddev() — Returns the standard deviation of the normal distribution