Fitting functions in the Stochastic DuckDB extension
Function category
Fitting
23 functionsAggregates that fit a distribution to a column by maximum likelihood and return its parameters as a STRUCT.
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a Bernoulli 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_bernoulli_fit(x) AS fit
FROM (VALUES (0), (1), (1), (0), (1), (1), (1), (0), (1), (0)) t(x);
Output
| fit |
|---|
| {'prob': 0.6, 'log_likelihood': -6.730116670092564, 'aic': 15.460233340185129, 'bic': 15.762818433179174} |
Related functions
- dist_bernoulli_pdf() — Computes the probability mass function (PMF) of the Bernoulli distribution at x
- dist_bernoulli_cdf() — Computes the cumulative distribution function (CDF) of the Bernoulli distribution, P(X <= x)
- dist_bernoulli_sample() — Generates a random sample from the Bernoulli distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a beta distribution to x by maximum likelihood (Newton's method). Returns a STRUCT with the fitted parameters (alpha, beta) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT dist_beta_fit(x) AS fit
FROM (VALUES (0.12), (0.31), (0.25), (0.08), (0.44), (0.19), (0.27)) t(x);
Output
| fit |
|---|
| {'alpha': 3.1333610763000657, 'beta': 10.103705554724225, 'log_likelihood': 5.691911425810101, 'aic': -7.383822851620202, 'bic': -7.492002553509575} |
Related functions
- dist_beta_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the beta distribution with the given parameters
- dist_beta_pdf() — Computes the probability density function (PDF) of the beta distribution at x
- dist_beta_cdf() — Computes the cumulative distribution function (CDF) of the beta distribution, P(X <= x)
- dist_beta_sample() — Generates a random sample from the beta distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
trials
|
Type
BIGINT
|
Mode Positional | Description |
Description
Fits a binomial 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. trials is the known number of trials and must be the same for every row of a group.
SELECT round(dist_binomial_fit(defects, 20).prob, 6) AS prob
FROM (VALUES (3), (5), (2), (4), (1), (3)) t(defects);
Output
| prob |
|---|
| 0.15 |
Related functions
- dist_binomial_pdf() — Computes the probability mass function (PMF) of the binomial distribution at x
- dist_binomial_cdf() — Computes the cumulative distribution function (CDF) of the binomial distribution, P(X <= x)
- dist_binomial_sample() — Generates a random sample from the binomial distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a Cauchy distribution to x by maximum likelihood (Newton's method). Returns a STRUCT with the fitted parameters (location, scale) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values. The whole sample is held in memory.
SELECT dist_cauchy_fit(x) AS fit
FROM (VALUES (0.2), (-0.5), (1.1), (0.4), (-0.1), (45.0), (0.7), (0.0)) t(x);
Output
| fit |
|---|
| {'location': 0.18918092986005372, 'scale': 0.3911158749331699, 'log_likelihood': -16.299967470868125, 'aic': 36.59993494173625, 'bic': 36.75881802509592} |
Related functions
- dist_cauchy_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the Cauchy distribution with the given parameters
- dist_cauchy_pdf() — Computes the probability density function (PDF) of the Cauchy distribution at x
- dist_cauchy_cdf() — Computes the cumulative distribution function (CDF) of the Cauchy distribution, P(X <= x)
- dist_cauchy_sample() — Generates a random sample from the Cauchy distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a chi-squared distribution to x by maximum likelihood (Newton's method). Returns a STRUCT with the fitted parameters (degrees_of_freedom) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT dist_chi_squared_fit(x) AS fit
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
| fit |
|---|
| {'degrees_of_freedom': 2.4395585639658903, 'log_likelihood': -16.65380346852325, 'aic': 35.3076069370465, 'bic': 35.610192030040544} |
Related functions
- dist_chi_squared_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the chi-squared distribution with the given parameters
- dist_chi_squared_pdf() — Computes the probability density function (PDF) of the chi-squared distribution at x
- dist_chi_squared_cdf() — Computes the cumulative distribution function (CDF) of the chi-squared distribution, P(X <= x)
- dist_chi_squared_sample() — Generates a random sample from the chi-squared distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a exponential distribution to x by maximum likelihood. Returns a STRUCT with the fitted parameters (rate) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT round(dist_exponential_fit(x).rate, 6) AS rate
FROM (VALUES (0.5), (1.2), (0.3), (2.0)) t(x);
Output
| rate |
|---|
| 1.0 |
Related functions
- dist_exponential_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the exponential distribution with the given parameters
- dist_exponential_pdf() — Computes the probability density function (PDF) of the exponential distribution at x
- dist_exponential_cdf() — Computes the cumulative distribution function (CDF) of the exponential distribution, P(X <= x)
- dist_exponential_sample() — Generates a random sample from the exponential distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a extreme value (Gumbel) distribution to x by maximum likelihood (Newton's method). Returns a STRUCT with the fitted parameters (location, scale) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values. The whole sample is held in memory.
SELECT dist_extreme_value_fit(x) AS fit
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
| fit |
|---|
| {'location': 1.3646057764916848, 'scale': 1.01710128234988, 'log_likelihood': -16.51499430573309, 'aic': 37.02998861146618, 'bic': 37.635158797454274} |
Related functions
- dist_extreme_value_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the extreme value (Gumbel) distribution with the given parameters
- dist_extreme_value_pdf() — Computes the probability density function (PDF) of the extreme value (Gumbel) distribution at x
- dist_extreme_value_cdf() — Computes the cumulative distribution function (CDF) of the extreme value (Gumbel) distribution, P(X <= x)
- dist_extreme_value_sample() — Generates a random sample from the extreme value (Gumbel) distribution with the specified parameters
Signature
2 overloaded forms · click to inspectArguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
candidates
|
Type
VARCHAR[]
|
Mode Positional | Description |
Description
Fits several distributions to x by maximum likelihood and ranks them by AICc, the AIC corrected for small samples. Returns a LIST with one STRUCT per candidate, best first: the distribution, its fitted parameters as a MAP, the log_likelihood, aic, aicc and bic of the fit, delta_aicc (the difference from the best AICc), aicc_weight (the Akaike weight, the relative likelihood of the candidate among those ranked) and a note. Candidates that cannot be ranked, because x is outside their support, there are too few values or the fit fails, come last with the reason in note. Without candidates, the continuous fits normal, lognormal, exponential, rayleigh, gamma, inverse_gamma, chi_squared, inverse_gaussian, beta, laplace, logistic, cauchy, extreme_value, weibull are tried. candidates names the fits to compare, either all continuous (those and uniform_real, pareto, students_t) or all discrete (poisson, bernoulli, geometric, negative_binomial). The uniform and Pareto are not tried by default because their fitted bounds are the sample extremes, which makes their AIC favor them. The whole sample of each group is held in memory.
SELECT f.distribution,
round(f.aicc, 2) AS aicc,
round(f.delta_aicc, 2) AS delta_aicc,
round(f.aicc_weight, 3) AS aicc_weight
FROM (
SELECT unnest(dist_fits(x, ['gamma', 'lognormal', 'normal'])) AS f
FROM (VALUES (2.1), (3.4), (2.9), (4.2), (3.3), (2.6), (5.8), (2.4)) t(x)
);
Output
| distribution | aicc | delta_aicc | aicc_weight |
|---|---|---|---|
| lognormal | 28.61 | 0.0 | 0.482 |
| gamma | 29.18 | 0.57 | 0.362 |
| normal | 30.86 | 2.25 | 0.156 |
SELECT list_transform(dist_fits(x)[1:3], lambda f: f.distribution) AS best
FROM (VALUES (2.1), (3.4), (2.9), (4.2), (3.3), (2.6), (5.8), (2.4)) t(x);
Output
| best |
|---|
| ['inverse_gamma', 'extreme_value', 'inverse_gaussian'] |
SELECT f.distribution, f.note
FROM (
SELECT unnest(dist_fits(x, ['normal', 'gamma'])) AS f
FROM (VALUES (-1.5), (0.5), (2.0), (0.7)) t(x)
);
Output
| distribution | note |
|---|---|
| normal | NULL |
| gamma | values must be > 0, got -1.5 |
Related functions
- dist_gamma_fit() — Fits a gamma distribution to x by maximum likelihood (Newton's method)
- dist_lognormal_fit() — Fits a log-normal distribution to x by maximum likelihood
- dist_normal_fit() — Fits a normal distribution to x by maximum likelihood
- dist_weibull_fit() — Fits a Weibull distribution to x by maximum likelihood (Newton's method)
- dist_gamma_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the gamma distribution with the given parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a gamma distribution to x by maximum likelihood (Newton's method). Returns a STRUCT with the fitted parameters (shape, scale) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT dist_gamma_fit(x) AS fit
FROM (VALUES (1.2), (0.7), (2.9), (1.8), (0.4), (3.6), (1.1), (2.2)) t(x);
Output
| fit |
|---|
| {'shape': 2.5167864710333365, 'scale': 0.6903644866171825, 'log_likelihood': -10.910661400281635, 'aic': 25.82132280056327, 'bic': 25.98020588392294} |
Related functions
- dist_gamma_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the gamma distribution with the given parameters
- dist_gamma_pdf() — Computes the probability density function (PDF) of the gamma distribution at x
- dist_gamma_cdf() — Computes the cumulative distribution function (CDF) of the gamma distribution, P(X <= x)
- dist_gamma_sample() — Generates a random sample from the gamma distribution with the specified parameters
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
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a inverse gamma distribution to x by maximum likelihood (Newton's method). Returns a STRUCT with the fitted parameters (shape, scale) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT dist_inverse_gamma_fit(x) AS fit
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
| fit |
|---|
| {'shape': 1.9456573675692381, 'scale': 2.2614739187025505, 'log_likelihood': -15.993196506604518, 'aic': 35.98639301320904, 'bic': 36.591563199197125} |
Related functions
- dist_inverse_gamma_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the inverse gamma distribution with the given parameters
- dist_inverse_gamma_pdf() — Computes the probability density function (PDF) of the inverse gamma distribution at x
- dist_inverse_gamma_cdf() — Computes the cumulative distribution function (CDF) of the inverse gamma distribution, P(X <= x)
- dist_inverse_gamma_sample() — Generates a random sample from the inverse gamma distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a inverse Gaussian distribution to x by maximum likelihood. Returns a STRUCT with the fitted parameters (mean, shape) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT dist_inverse_gaussian_fit(x) AS fit
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
| fit |
|---|
| {'mean': 2.01, 'shape': 2.756060007033965, 'log_likelihood': -15.553726161412696, 'aic': 35.107452322825395, 'bic': 35.71262250881348} |
Related functions
- dist_inverse_gaussian_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the inverse Gaussian (Wald) distribution with the given parameters
- dist_inverse_gaussian_pdf() — Computes the probability density function (PDF) of the inverse Gaussian (Wald) distribution at x
- dist_inverse_gaussian_cdf() — Computes the cumulative distribution function (CDF) of the inverse Gaussian (Wald) distribution, P(X <= x)
- dist_inverse_gaussian_sample() — Generates a random sample from the inverse Gaussian (Wald) distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a Laplace distribution to x by maximum likelihood (the median and the mean absolute deviation from it). Returns a STRUCT with the fitted parameters (location, scale) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values. The whole sample is held in memory.
SELECT dist_laplace_fit(x) AS fit
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
| fit |
|---|
| {'location': 1.5, 'scale': 1.15, 'log_likelihood': -18.32909122935104, 'aic': 40.65818245870208, 'bic': 41.26335264469017} |
Related functions
- dist_laplace_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the Laplace distribution with the given parameters
- dist_laplace_pdf() — Computes the probability density function (PDF) of the Laplace distribution at x
- dist_laplace_cdf() — Computes the cumulative distribution function (CDF) of the Laplace distribution, P(X <= x)
- dist_laplace_sample() — Generates a random sample from the Laplace distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a logistic distribution to x by maximum likelihood (Newton's method). Returns a STRUCT with the fitted parameters (location, scale) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values. The whole sample is held in memory.
SELECT round(dist_logistic_fit(x).aic, 4) AS logistic_aic, round(dist_normal_fit(x).aic, 4) AS normal_aic
FROM (VALUES (0.2), (-0.5), (1.1), (0.4), (-0.1), (2.9), (0.7), (0.0), (-1.8), (0.3)) t(x);
Output
| logistic_aic | normal_aic |
|---|---|
| 34.0263 | 34.9066 |
Related functions
- dist_logistic_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the logistic distribution with the given parameters
- dist_logistic_pdf() — Computes the probability density function (PDF) of the logistic distribution at x
- dist_logistic_cdf() — Computes the cumulative distribution function (CDF) of the logistic distribution, P(X <= x)
- dist_logistic_sample() — Generates a random sample from the logistic distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a log-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_lognormal_fit(x) AS fit
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
| fit |
|---|
| {'mean': 0.4288900973406523, 'stddev': 0.7552197869158146, 'log_likelihood': -15.670821669461231, 'aic': 35.34164333892247, 'bic': 35.94681352491055} |
Related functions
- dist_lognormal_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the log-normal distribution with the given parameters
- dist_lognormal_pdf() — Computes the probability density function (PDF) of the log-normal distribution at x
- dist_lognormal_cdf() — Computes the cumulative distribution function (CDF) of the log-normal distribution, P(X <= x)
- dist_lognormal_sample() — Generates a random sample from the log-normal distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a negative binomial distribution to x by maximum likelihood. Returns a STRUCT with the fitted parameters (successes, prob) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values. successes is restricted to whole numbers, as the distribution functions require; cast it to BIGINT to use it. Returns NULL when the variance does not exceed the mean. The whole sample is held in memory.
SELECT dist_negative_binomial_fit(x) AS fit
FROM (VALUES (0), (3), (1), (7), (2), (12), (0), (5), (1), (9)) t(x);
Output
| fit |
|---|
| {'successes': 1.0, 'prob': 0.2, 'log_likelihood': -25.02012117690939, 'aic': 54.04024235381878, 'bic': 54.64541253980688} |
Related functions
- dist_negative_binomial_pdf() — Computes the probability mass function (PMF) of the negative binomial distribution at x
- dist_negative_binomial_cdf() — Computes the cumulative distribution function (CDF) of the negative binomial distribution, P(X <= x)
- dist_negative_binomial_sample() — Generates a random sample from the negative binomial distribution with the specified parameters
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
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a Pareto distribution to x by maximum likelihood. Returns a STRUCT with the fitted parameters (scale, shape) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT dist_pareto_fit(x) AS fit
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
| fit |
|---|
| {'scale': 0.4, 'shape': 0.7433944777399986, 'log_likelihood': -17.254185468703348, 'aic': 38.508370937406696, 'bic': 39.11354112339479} |
Related functions
- dist_pareto_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the Pareto distribution with the given parameters
- dist_pareto_pdf() — Positional arguments are `(scale, shape)`, both positive and finite
- dist_pareto_cdf() — Positional arguments are `(scale, shape)`, both positive and finite
- dist_pareto_sample() — Positional arguments are `(scale, shape)`, both positive and finite
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a Poisson distribution to x by maximum likelihood. Returns a STRUCT with the fitted parameters (rate) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT dist_poisson_fit(x).rate AS rate
FROM (VALUES (3), (5), (2), (4), (6), (4)) t(x);
Output
| rate |
|---|
| 4.0 |
Related functions
- dist_poisson_pdf() — Computes the probability mass function (PMF) of the Poisson distribution at x
- dist_poisson_cdf() — Computes the cumulative distribution function (CDF) of the Poisson distribution, P(X <= x)
- dist_poisson_sample() — Generates a random sample from the Poisson distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a Rayleigh distribution to x by maximum likelihood. Returns a STRUCT with the fitted parameters (scale) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT dist_rayleigh_fit(x) AS fit
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
| fit |
|---|
| {'scale': 1.7557049866079437, 'log_likelihood': -16.968508587157096, 'aic': 35.93701717431419, 'bic': 36.239602267308236} |
Related functions
- dist_rayleigh_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the Rayleigh distribution with the given parameters
- dist_rayleigh_pdf() — Computes the probability density function (PDF) of the Rayleigh distribution at x
- dist_rayleigh_cdf() — Computes the cumulative distribution function (CDF) of the Rayleigh distribution, P(X <= x)
- dist_rayleigh_sample() — Generates a random sample from the Rayleigh distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a standard Student's t distribution to x by maximum likelihood (golden section search). Returns a STRUCT with the fitted parameters (degrees_of_freedom) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values. Returns NULL when the tails are no heavier than normal, where the degrees of freedom are unbounded. The whole sample is held in memory.
SELECT dist_students_t_fit(x) AS fit
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
| fit |
|---|
| {'degrees_of_freedom': 1.413024185041085, 'log_likelihood': -25.52061409183976, 'aic': 53.04122818367952, 'bic': 53.343813276673565} |
Related functions
- dist_students_t_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the Student's t distribution with the given parameters
- dist_students_t_pdf() — Computes the probability density function (PDF) of the Student's t distribution at x
- dist_students_t_cdf() — Computes the cumulative distribution function (CDF) of the Student's t distribution, P(X <= x)
- dist_students_t_sample() — Generates a random sample from the Student's t distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a continuous uniform distribution to x by maximum likelihood (the sample minimum and maximum). Returns a STRUCT with the fitted parameters (min, max) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values.
SELECT dist_uniform_real_fit(x) AS fit
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
| fit |
|---|
| {'min': 0.4, 'max': 5.3, 'log_likelihood': -15.892352051165808, 'aic': 35.78470410233162, 'bic': 36.38987428831971} |
Related functions
- dist_uniform_real_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the continuous uniform distribution with the given parameters
- dist_uniform_real_pdf() — Computes the probability density function (PDF) of the continuous uniform distribution at x
- dist_uniform_real_cdf() — Computes the cumulative distribution function (CDF) of the continuous uniform distribution, P(X <= x)
- dist_uniform_real_sample() — Generates a random sample from the continuous uniform distribution with the specified parameters
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
x
|
Type
DOUBLE
|
Mode Positional | Description |
Description
Fits a Weibull distribution to x by maximum likelihood (Newton's method). Returns a STRUCT with the fitted parameters (shape, scale) followed by the log_likelihood, aic and bic of the fit, or NULL when there are too few or only identical values. The whole sample is held in memory.
SELECT dist_weibull_fit(x) AS fit
FROM (VALUES (2.1), (3.4), (1.7), (4.0), (2.8), (3.1), (1.2), (2.5)) t(x);
Output
| fit |
|---|
| {'shape': 3.4183090905293314, 'scale': 2.90120446838219, 'log_likelihood': -10.022056053941597, 'aic': 24.044112107883194, 'bic': 24.202995191242866} |
Related functions
- dist_weibull_ks_test() — One-sample Kolmogorov-Smirnov test of whether x follows the Weibull distribution with the given parameters
- dist_weibull_pdf() — Computes the probability density function (PDF) of the Weibull distribution at x
- dist_weibull_cdf() — Computes the cumulative distribution function (CDF) of the Weibull distribution, P(X <= x)
- dist_weibull_sample() — Generates a random sample from the Weibull distribution with the specified parameters