pg_math
pg_math
pg_math : GSL statistical functions for postgresql
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4780 | pg_math
|
pg_math
|
1.1.0 |
FUNC
|
GPL-3.0
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r
|
No
|
Yes
|
No
|
Yes
|
yes
|
no
|
| Relationships | |
|---|---|
| See Also | pg_idkit
pgx_ulid
pg_uuidv7
permuteseq
pg_hashids
sequential_uuids
topn
quantile
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
1.1.0 |
18
17
16
15
14
|
pg_math |
- |
| RPM | PIGSTY
|
1.1.0 |
18
17
16
15
14
|
pg_math_$v |
- |
| DEB | PIGSTY
|
1.1.0 |
18
17
16
15
14
|
postgresql-$v-pg-math |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
el8.aarch64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
el9.x86_64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
el9.aarch64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
el10.x86_64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
el10.aarch64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
d12.x86_64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
d12.aarch64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
d13.x86_64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
d13.aarch64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
u22.x86_64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
u22.aarch64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
u24.x86_64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
u24.aarch64
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
PIGSTY 1.1.0
|
Source
pig build pkg pg_math; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pg_math; # install via package name, for the active PG version
pig install pg_math -v 18; # install for PG 18
pig install pg_math -v 17; # install for PG 17
pig install pg_math -v 16; # install for PG 16
pig install pg_math -v 15; # install for PG 15
pig install pg_math -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION pg_math;Usage
pg_math: statistical distribution functions using GSL for PostgreSQL
Provides CDF (cumulative distribution) and RDF (random distribution) functions for 31 statistical distributions using the GNU Scientific Library (GSL).
CREATE EXTENSION pg_math;Supported Distributions
Gaussian, Unit Gaussian, Gaussian Tail, Bivariate Gaussian, F-Distribution, Exponential, Laplace, Exponential Power, Cauchy, Rayleigh, Rayleigh Tail, Landau, Gamma, Flat (Uniform), Lognormal, Chi-squared, T-Distribution, Beta, Logistic, Pareto, Weibull, Type-1 Gumbel, Type-2 Gumbel, Poisson, Bernoulli, Binomial, Negative Binomial, Pascal, Geometric, Hypergeometric, Logarithmic.
Function Naming Convention
rdf_<distribution>(...)– random distribution function (PDF value)cdf_<distribution>_p(...)– cumulative distribution P-valuecdf_<distribution>_q(...)– cumulative distribution Q-value (1-P)cdf_<distribution>_pinv(...)– inverse CDF Pcdf_<distribution>_qinv(...)– inverse CDF Q
Examples
-- Gaussian distribution
SELECT rdf_gaussian(1.5, 2.0); -- PDF at x=1.5, sigma=2.0
SELECT cdf_gaussian_p(1.5, 2.0); -- CDF P-value
-- Unit Gaussian (standard normal)
SELECT cdf_unit_gaussian_p(1.96); -- ~0.975
-- Chi-squared distribution
SELECT cdf_chisq_p(3.84, 1.0); -- ~0.95
-- T-distribution
SELECT cdf_tdist_pinv(0.975, 10.0); -- critical value for 95% CI with df=10
-- Poisson distribution
SELECT rdf_poisson(5, 3.0); -- P(X=5) with lambda=3
-- Beta distribution
SELECT rdf_beta(0.5, 2.0, 5.0); -- PDF at x=0.5, a=2, b=5Last updated on