Triangular functions in the Stochastic DuckDB extension
Function category
Triangular
23 functionsTriangular on [lower, upper] with a mode — a simple prior from minimum, most likely and maximum estimates. PERT-style estimates.
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the cumulative distribution function (CDF) of the triangular distribution, P(X <= x).
SELECT dist_triangular_cdf(0.0, 0.5, 1.0, 0.25);
Output
| dist_triangular_cdf(0.0, 0.5, 1.0, 0.25) |
|---|
| 0.125 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the complementary cumulative distribution function (survival function) of the triangular distribution, P(X > x).
SELECT dist_triangular_cdf_complement(0.0, 0.5, 1.0, 0.25);
Output
| dist_triangular_cdf_complement(0.0, 0.5, 1.0, 0.25) |
|---|
| 0.875 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the cumulative hazard function of the triangular distribution at x.
SELECT dist_triangular_chf(0.0, 0.5, 1.0, 0.25);
Output
| dist_triangular_chf(0.0, 0.5, 1.0, 0.25) |
|---|
| 0.13353139262452263 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the hazard function of the triangular distribution at x.
SELECT dist_triangular_hazard(0.0, 0.5, 1.0, 0.25);
Output
| dist_triangular_hazard(0.0, 0.5, 1.0, 0.25) |
|---|
| 1.1428571428571428 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
One-sample Kolmogorov-Smirnov test of whether x follows the triangular distribution with the given parameters. Returns the statistic D and the asymptotic p-value.
SELECT dist_triangular_ks_test(x, 0.0, 0.5, 1.0) AS ks
FROM (VALUES (1.2), (0.7), (2.9), (1.8), (0.4), (3.6), (1.1), (2.2), (5.3), (0.9)) t(x);
Output
| ks |
|---|
| {'statistic': 0.78, 'p_value': 1.0388066948005695e-05} |
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the kurtosis of the triangular distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_triangular_kurtosis(0.0, 0.5, 1.0);
Output
| dist_triangular_kurtosis(0.0, 0.5, 1.0) |
|---|
| 2.4 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the excess kurtosis of the triangular distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_triangular_kurtosis_excess(0.0, 0.5, 1.0);
Output
| dist_triangular_kurtosis_excess(0.0, 0.5, 1.0) |
|---|
| -0.6 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
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 triangular distribution.
SELECT dist_triangular_log_cdf(0.0, 0.5, 1.0, 0.25);
Output
| dist_triangular_log_cdf(0.0, 0.5, 1.0, 0.25) |
|---|
| -2.0794415416798357 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the natural logarithm of the survival function of the triangular distribution, log P(X > x).
SELECT dist_triangular_log_cdf_complement(0.0, 0.5, 1.0, 0.25);
Output
| dist_triangular_log_cdf_complement(0.0, 0.5, 1.0, 0.25) |
|---|
| -0.13353139262452263 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
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 triangular distribution at x. Useful for numerical stability when dealing with very small probabilities.
SELECT dist_triangular_log_pdf(0.0, 0.5, 1.0, 0.25);
Output
| dist_triangular_log_pdf(0.0, 0.5, 1.0, 0.25) |
|---|
| 0.0 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the mean of the triangular distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_triangular_mean(0.0, 0.5, 1.0);
Output
| dist_triangular_mean(0.0, 0.5, 1.0) |
|---|
| 0.5 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the median of the triangular distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_triangular_median(0.0, 0.5, 1.0);
Output
| dist_triangular_median(0.0, 0.5, 1.0) |
|---|
| 0.5 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the mode (most likely value) of the triangular distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_triangular_mode(0.0, 0.5, 1.0);
Output
| dist_triangular_mode(0.0, 0.5, 1.0) |
|---|
| 0.5 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the probability density function (PDF) of the triangular distribution at x.
SELECT dist_triangular_pdf(0.0, 0.5, 1.0, 0.25);
Output
| dist_triangular_pdf(0.0, 0.5, 1.0, 0.25) |
|---|
| 1.0 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
p
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the quantile function (inverse CDF) of the triangular distribution. Returns the smallest x such that P(X <= x) >= p.
SELECT round(dist_triangular_quantile(2.0, 3.0, 7.0, 0.5), 4) AS median_days;
Output
| median_days |
|---|
| 3.8377 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
p
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the complementary quantile function of the triangular distribution. Returns x such that P(X > x) = p, useful for upper tail quantiles.
SELECT dist_triangular_quantile_complement(0.0, 0.5, 1.0, 0.95);
Output
| dist_triangular_quantile_complement(0.0, 0.5, 1.0, 0.95) |
|---|
| 0.15811388300841903 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the range of the triangular distribution as [min, max].
SELECT dist_triangular_range(0.0, 0.5, 1.0);
Output
| dist_triangular_range(0.0, 0.5, 1.0) |
|---|
| [-inf, inf] |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Generates a random sample from the triangular distribution with the specified parameters.
SELECT dist_triangular_sample(0.0, 0.5, 1.0);
Output
| dist_triangular_sample(0.0, 0.5, 1.0) |
|---|
| 0.27740823005395016 |
Related functions
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
n
|
Type
BIGINT
|
Mode Positional | Description |
Description
Generates a list of n random samples from the triangular distribution with the specified parameters.
SELECT dist_triangular_samples(0.0, 0.5, 1.0, 5);
Output
| dist_triangular_samples(0.0, 0.5, 1.0, 5) |
|---|
| [0.33890389769605667, 0.5094722624361524, 0.4987536254128971, 0.4689277423200763, 0.5005507275035932] |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the skewness of the triangular distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_triangular_skewness(0.0, 0.5, 1.0);
Output
| dist_triangular_skewness(0.0, 0.5, 1.0) |
|---|
| 0.0 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the standard deviation of the triangular distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_triangular_stddev(0.0, 0.5, 1.0);
Output
| dist_triangular_stddev(0.0, 0.5, 1.0) |
|---|
| 0.2041241452319315 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the support of the triangular distribution as [min, max].
SELECT dist_triangular_support(0.0, 0.5, 1.0);
Output
| dist_triangular_support(0.0, 0.5, 1.0) |
|---|
| [0.0, 1.0] |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
lower
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
mode
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
upper
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the variance of the triangular distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_triangular_variance(0.0, 0.5, 1.0);
Output
| dist_triangular_variance(0.0, 0.5, 1.0) |
|---|
| 0.041666666666666664 |
Related functions
- dist_triangular_sample() — Generates a random sample from the triangular distribution with the specified parameters
- dist_triangular_pdf() — Computes the probability density function (PDF) of the triangular distribution at x
- dist_triangular_quantile() — Computes the quantile function (inverse CDF) of the triangular distribution
- dist_triangular_mean() — Returns the mean of the triangular distribution
- dist_triangular_stddev() — Returns the standard deviation of the triangular distribution