Multinomial functions in the Stochastic DuckDB extension
Function category
Multinomial
7 functionsMultinomial — counts of each outcome across a fixed number of categorical trials. Generalizes the Binomial to k categories.
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
trials
|
Type
BIGINT
|
Mode Positional | Description |
Argument
probs
|
Type
DOUBLE[]
|
Mode Positional | Description |
Argument
x
|
Type
BIGINT[]
|
Mode Positional | Description |
Description
Computes the natural logarithm of the probability mass function (PMF) of the multinomial distribution at the counts x.
SELECT dist_multinomial_log_pdf(10, [0.2, 0.3, 0.5], [2, 3, 5]);
Output
| dist_multinomial_log_pdf(10, list_value(0.2, 0.3, 0.5), list_value(2, 3, 5)) |
|---|
| -2.4645159601402677 |
Related functions
- dist_multinomial_sample() — Generates a random sample from the multinomial distribution: the counts of each outcome in trials draws with outcome probabilities probs
- dist_multinomial_pdf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_pmf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_mean() — Returns the mean count of each outcome of the multinomial distribution, trials * probs_i
- dist_multinomial_variance() — Returns the variance of the count of each outcome of the multinomial distribution, trials * p_i * (1 - p_i)
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
trials
|
Type
BIGINT
|
Mode Positional | Description |
Argument
probs
|
Type
DOUBLE[]
|
Mode Positional | Description |
Argument
x
|
Type
BIGINT[]
|
Mode Positional | Description |
Description
Computes the natural logarithm of the probability mass function (PMF) of the multinomial distribution at the counts x.
SELECT dist_multinomial_log_pmf(10, [0.2, 0.3, 0.5], [2, 3, 5]);
Output
| dist_multinomial_log_pmf(10, list_value(0.2, 0.3, 0.5), list_value(2, 3, 5)) |
|---|
| -2.4645159601402677 |
Related functions
- dist_multinomial_sample() — Generates a random sample from the multinomial distribution: the counts of each outcome in trials draws with outcome probabilities probs
- dist_multinomial_pdf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_pmf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_mean() — Returns the mean count of each outcome of the multinomial distribution, trials * probs_i
- dist_multinomial_variance() — Returns the variance of the count of each outcome of the multinomial distribution, trials * p_i * (1 - p_i)
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
trials
|
Type
BIGINT
|
Mode Positional | Description |
Argument
probs
|
Type
DOUBLE[]
|
Mode Positional | Description |
Description
Returns the mean count of each outcome of the multinomial distribution, trials * probs_i.
SELECT dist_multinomial_mean(10, [0.2, 0.3, 0.5]) AS mean;
Output
| mean |
|---|
| [2.0, 3.0, 5.0] |
Related functions
- dist_multinomial_sample() — Generates a random sample from the multinomial distribution: the counts of each outcome in trials draws with outcome probabilities probs
- dist_multinomial_pdf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_pmf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_variance() — Returns the variance of the count of each outcome of the multinomial distribution, trials * p_i * (1 - p_i)
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
trials
|
Type
BIGINT
|
Mode Positional | Description |
Argument
probs
|
Type
DOUBLE[]
|
Mode Positional | Description |
Argument
x
|
Type
BIGINT[]
|
Mode Positional | Description |
Description
Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x.
SELECT dist_multinomial_pdf(10, [0.2, 0.3, 0.5], [2, 3, 5]);
Output
| dist_multinomial_pdf(10, list_value(0.2, 0.3, 0.5), list_value(2, 3, 5)) |
|---|
| 0.08504999999999988 |
Related functions
- dist_multinomial_sample() — Generates a random sample from the multinomial distribution: the counts of each outcome in trials draws with outcome probabilities probs
- dist_multinomial_pmf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_mean() — Returns the mean count of each outcome of the multinomial distribution, trials * probs_i
- dist_multinomial_variance() — Returns the variance of the count of each outcome of the multinomial distribution, trials * p_i * (1 - p_i)
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
trials
|
Type
BIGINT
|
Mode Positional | Description |
Argument
probs
|
Type
DOUBLE[]
|
Mode Positional | Description |
Argument
x
|
Type
BIGINT[]
|
Mode Positional | Description |
Description
Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x.
SELECT round(dist_multinomial_pmf(10, [0.2, 0.3, 0.5], [2, 3, 5]), 6) AS prob;
Output
| prob |
|---|
| 0.08505 |
Related functions
- dist_multinomial_sample() — Generates a random sample from the multinomial distribution: the counts of each outcome in trials draws with outcome probabilities probs
- dist_multinomial_pdf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_mean() — Returns the mean count of each outcome of the multinomial distribution, trials * probs_i
- dist_multinomial_variance() — Returns the variance of the count of each outcome of the multinomial distribution, trials * p_i * (1 - p_i)
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
trials
|
Type
BIGINT
|
Mode Positional | Description |
Argument
probs
|
Type
DOUBLE[]
|
Mode Positional | Description |
Description
Generates a random sample from the multinomial distribution: the counts of each outcome in trials draws with outcome probabilities probs. Returns a list of counts that sums to trials.
SELECT list_sum(dist_multinomial_sample(10, [0.2, 0.3, 0.5])) AS total;
Output
| total |
|---|
| 10 |
Related functions
- dist_multinomial_pdf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_pmf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_mean() — Returns the mean count of each outcome of the multinomial distribution, trials * probs_i
- dist_multinomial_variance() — Returns the variance of the count of each outcome of the multinomial distribution, trials * p_i * (1 - p_i)
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
trials
|
Type
BIGINT
|
Mode Positional | Description |
Argument
probs
|
Type
DOUBLE[]
|
Mode Positional | Description |
Description
Returns the variance of the count of each outcome of the multinomial distribution, trials * p_i * (1 - p_i).
SELECT dist_multinomial_variance(10, [0.2, 0.3, 0.5]);
Output
| dist_multinomial_variance(10, list_value(0.2, 0.3, 0.5)) |
|---|
| [1.6, 2.0999999999999996, 2.5] |
Related functions
- dist_multinomial_sample() — Generates a random sample from the multinomial distribution: the counts of each outcome in trials draws with outcome probabilities probs
- dist_multinomial_pdf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_pmf() — Computes the probability mass function (PMF) of the multinomial distribution: the probability of observing the counts x
- dist_multinomial_mean() — Returns the mean count of each outcome of the multinomial distribution, trials * probs_i