Geometric functions in the Stochastic DuckDB extension
Function category
Geometric
25 functionsGeometric — number of failures before the first success in a Bernoulli trial sequence.
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x).
SELECT dist_geometric_cdf(0.5, 2);
Output
| dist_geometric_cdf(0.5, 2) |
|---|
| 0.875 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the complementary cumulative distribution function (survival function) of the geometric distribution, P(X > x).
SELECT dist_geometric_cdf_complement(0.5, 2);
Output
| dist_geometric_cdf_complement(0.5, 2) |
|---|
| 0.12500000000000003 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the cumulative hazard function of the geometric distribution at x.
SELECT dist_geometric_chf(0.5, 2);
Output
| dist_geometric_chf(0.5, 2) |
|---|
| 2.0794415416798357 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a geometric (failures before the first success) distribution to x by maximum likelihood. Returns a STRUCT with the fitted parameters (prob) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT dist_geometric_fit(x) AS fit
FROM (VALUES (2), (3), (1), (4), (2), (5), (3), (2), (6), (3)) t(x);
Output
| fit |
|---|
| {'prob': 0.24390243902439027, 'log_likelihood': -22.777000465896627, 'aic': 47.554000931793254, 'bic': 47.8565860247873} |
Related functions
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the hazard function of the geometric distribution at x.
SELECT dist_geometric_hazard(0.5, 2);
Output
| dist_geometric_hazard(0.5, 2) |
|---|
| 0.9999999999999998 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the kurtosis of the geometric distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_geometric_kurtosis(0.5);
Output
| dist_geometric_kurtosis(0.5) |
|---|
| 9.5 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the excess kurtosis of the geometric distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_geometric_kurtosis_excess(0.5);
Output
| dist_geometric_kurtosis_excess(0.5) |
|---|
| 6.5 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
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 geometric distribution.
SELECT dist_geometric_log_cdf(0.5, 2);
Output
| dist_geometric_log_cdf(0.5, 2) |
|---|
| -0.13353139262452265 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the natural logarithm of the survival function of the geometric distribution, log P(X > x).
SELECT dist_geometric_log_cdf_complement(0.5, 2);
Output
| dist_geometric_log_cdf_complement(0.5, 2) |
|---|
| -2.0794415416798357 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the natural logarithm of the probability mass function (PMF) of the geometric distribution at x. Useful for numerical stability when dealing with very small probabilities.
SELECT dist_geometric_log_pdf(0.5, 2);
Output
| dist_geometric_log_pdf(0.5, 2) |
|---|
| -2.0794415416798357 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the natural logarithm of the probability mass function (PMF) of the geometric distribution at x.
SELECT dist_geometric_log_pmf(0.5, 2);
Output
| dist_geometric_log_pmf(0.5, 2) |
|---|
| -2.0794415416798357 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the mean of the geometric distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_geometric_mean(0.5);
Output
| dist_geometric_mean(0.5) |
|---|
| 1.0 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the median of the geometric distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_geometric_median(0.5);
Output
| dist_geometric_median(0.5) |
|---|
| 0.0 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the mode (most likely value) of the geometric distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_geometric_mode(0.5);
Output
| dist_geometric_mode(0.5) |
|---|
| 0.0 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the probability mass function (PMF) of the geometric distribution at x.
SELECT dist_geometric_pdf(0.5, 2);
Output
| dist_geometric_pdf(0.5, 2) |
|---|
| 0.125 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the probability mass function (PMF) of the geometric distribution at x, P(X = x).
SELECT dist_geometric_pmf(0.5, 2);
Output
| dist_geometric_pmf(0.5, 2) |
|---|
| 0.125 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
p
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the quantile function (inverse CDF) of the geometric distribution. Returns the smallest x such that P(X <= x) >= p.
SELECT dist_geometric_quantile(0.5, 0.95);
Output
| dist_geometric_quantile(0.5, 0.95) |
|---|
| 4.0 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
p
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Computes the complementary quantile function of the geometric distribution. Returns x such that P(X > x) = p, useful for upper tail quantiles.
SELECT dist_geometric_quantile_complement(0.5, 0.95);
Output
| dist_geometric_quantile_complement(0.5, 0.95) |
|---|
| 0.0 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the range of the geometric distribution as [min, max].
SELECT dist_geometric_range(0.5);
Output
| dist_geometric_range(0.5) |
|---|
| [0.0, inf] |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Generates a random sample from the geometric distribution with the specified parameters.
SELECT dist_geometric_sample(0.5);
Output
| dist_geometric_sample(0.5) |
|---|
| 0 |
Related functions
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
n
|
Type
BIGINT
|
Mode Positional | Description |
Description
Generates a list of n random samples from the geometric distribution with the specified parameters.
SELECT dist_geometric_samples(0.5, 5);
Output
| dist_geometric_samples(0.5, 5) |
|---|
| [4, 0, 1, 2, 2] |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the skewness of the geometric distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_geometric_skewness(0.5);
Output
| dist_geometric_skewness(0.5) |
|---|
| 2.1213203435596424 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the standard deviation of the geometric distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_geometric_stddev(0.5);
Output
| dist_geometric_stddev(0.5) |
|---|
| 1.4142135623730951 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the support of the geometric distribution as [min, max].
SELECT dist_geometric_support(0.5);
Output
| dist_geometric_support(0.5) |
|---|
| [0.0, inf] |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
prob
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Returns the variance of the geometric distribution. Returns NULL when it is undefined for the given parameters.
SELECT dist_geometric_variance(0.5);
Output
| dist_geometric_variance(0.5) |
|---|
| 2.0 |
Related functions
- dist_geometric_sample() — Generates a random sample from the geometric distribution with the specified parameters
- dist_geometric_pdf() — Computes the probability mass function (PMF) of the geometric distribution at x
- dist_geometric_cdf() — Computes the cumulative distribution function (CDF) of the geometric distribution, P(X <= x)
- dist_geometric_quantile() — Computes the quantile function (inverse CDF) of the geometric distribution
- dist_geometric_mean() — Returns the mean of the geometric distribution
- dist_geometric_stddev() — Returns the standard deviation of the geometric distribution