Skip to content

pg_math

GSL statistical functions for postgresql

pg_math · GSL statistical functions for postgresql

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4790pg_mathpg_math1.1.0FUNCMITC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.1.019 18 17 16 15pg_math-
RPMPIGSTY1.1.019 18 17 16 15pg_math_$v-
DEBPIGSTY1.1.019 18 17 16 15postgresql-$v-pg-math-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el8.aarch64N/APIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el9.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el9.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el10.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el10.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d12.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d12.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d13.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d13.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u22.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u22.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u24.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u24.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u26.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u26.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
PackageVersionOSORGSIZEFile URL
pg_math_191.1.0el9.x86_64pigsty72.5 KiBpg_math_19-1.1.0-1PGSTY.el9.x86_64.rpm
pg_math_191.1.0el9.aarch64pigsty71.0 KiBpg_math_19-1.1.0-1PGSTY.el9.aarch64.rpm
pg_math_191.1.0el10.x86_64pigsty72.9 KiBpg_math_19-1.1.0-1PGSTY.el10.x86_64.rpm
pg_math_191.1.0el10.aarch64pigsty71.4 KiBpg_math_19-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-math1.1.0d12.x86_64pigsty60.8 KiBpostgresql-19-pg-math_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-math1.1.0d12.aarch64pigsty59.9 KiBpostgresql-19-pg-math_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-math1.1.0d13.x86_64pigsty60.7 KiBpostgresql-19-pg-math_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-19-pg-math1.1.0d13.aarch64pigsty60.2 KiBpostgresql-19-pg-math_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-19-pg-math1.1.0u22.x86_64pigsty68.2 KiBpostgresql-19-pg-math_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-19-pg-math1.1.0u22.aarch64pigsty67.1 KiBpostgresql-19-pg-math_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-19-pg-math1.1.0u24.x86_64pigsty65.0 KiBpostgresql-19-pg-math_1.1.0-1PGSTY~noble_amd64.deb
postgresql-19-pg-math1.1.0u24.aarch64pigsty63.9 KiBpostgresql-19-pg-math_1.1.0-1PGSTY~noble_arm64.deb
postgresql-19-pg-math1.1.0u26.x86_64pigsty64.1 KiBpostgresql-19-pg-math_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-19-pg-math1.1.0u26.aarch64pigsty63.6 KiBpostgresql-19-pg-math_1.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_math_181.1.0el8.x86_64pigsty70.9 KiBpg_math_18-1.1.0-1PGSTY.el8.x86_64.rpm
pg_math_181.1.0el8.aarch64pigsty69.3 KiBpg_math_18-1.1.0-1PGSTY.el8.aarch64.rpm
pg_math_181.1.0el9.x86_64pigsty73.0 KiBpg_math_18-1.1.0-1PGSTY.el9.x86_64.rpm
pg_math_181.1.0el9.aarch64pigsty71.0 KiBpg_math_18-1.1.0-1PGSTY.el9.aarch64.rpm
pg_math_181.1.0el10.x86_64pigsty72.4 KiBpg_math_18-1.1.0-1PGSTY.el10.x86_64.rpm
pg_math_181.1.0el10.aarch64pigsty71.4 KiBpg_math_18-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-math1.1.0d12.x86_64pigsty60.9 KiBpostgresql-18-pg-math_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-math1.1.0d12.aarch64pigsty59.9 KiBpostgresql-18-pg-math_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-math1.1.0d13.x86_64pigsty60.7 KiBpostgresql-18-pg-math_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-math1.1.0d13.aarch64pigsty60.3 KiBpostgresql-18-pg-math_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-math1.1.0u22.x86_64pigsty68.2 KiBpostgresql-18-pg-math_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-math1.1.0u22.aarch64pigsty67.1 KiBpostgresql-18-pg-math_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-math1.1.0u24.x86_64pigsty65.0 KiBpostgresql-18-pg-math_1.1.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-math1.1.0u24.aarch64pigsty63.9 KiBpostgresql-18-pg-math_1.1.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-math1.1.0u26.x86_64pigsty64.1 KiBpostgresql-18-pg-math_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-math1.1.0u26.aarch64pigsty63.5 KiBpostgresql-18-pg-math_1.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_math_171.1.0el8.x86_64pigsty70.9 KiBpg_math_17-1.1.0-1PGSTY.el8.x86_64.rpm
pg_math_171.1.0el8.aarch64pigsty69.3 KiBpg_math_17-1.1.0-1PGSTY.el8.aarch64.rpm
pg_math_171.1.0el9.x86_64pigsty72.9 KiBpg_math_17-1.1.0-1PGSTY.el9.x86_64.rpm
pg_math_171.1.0el9.aarch64pigsty70.9 KiBpg_math_17-1.1.0-1PGSTY.el9.aarch64.rpm
pg_math_171.1.0el10.x86_64pigsty72.8 KiBpg_math_17-1.1.0-1PGSTY.el10.x86_64.rpm
pg_math_171.1.0el10.aarch64pigsty71.3 KiBpg_math_17-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-math1.1.0d12.x86_64pigsty61.0 KiBpostgresql-17-pg-math_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-math1.1.0d12.aarch64pigsty59.8 KiBpostgresql-17-pg-math_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-math1.1.0d13.x86_64pigsty60.6 KiBpostgresql-17-pg-math_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-math1.1.0d13.aarch64pigsty60.1 KiBpostgresql-17-pg-math_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-math1.1.0u22.x86_64pigsty68.9 KiBpostgresql-17-pg-math_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-math1.1.0u22.aarch64pigsty67.9 KiBpostgresql-17-pg-math_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-math1.1.0u24.x86_64pigsty64.9 KiBpostgresql-17-pg-math_1.1.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-math1.1.0u24.aarch64pigsty63.8 KiBpostgresql-17-pg-math_1.1.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-math1.1.0u26.x86_64pigsty64.1 KiBpostgresql-17-pg-math_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-math1.1.0u26.aarch64pigsty63.4 KiBpostgresql-17-pg-math_1.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_math_161.1.0el8.x86_64pigsty70.9 KiBpg_math_16-1.1.0-1PGSTY.el8.x86_64.rpm
pg_math_161.1.0el8.aarch64pigsty69.3 KiBpg_math_16-1.1.0-1PGSTY.el8.aarch64.rpm
pg_math_161.1.0el9.x86_64pigsty72.9 KiBpg_math_16-1.1.0-1PGSTY.el9.x86_64.rpm
pg_math_161.1.0el9.aarch64pigsty70.9 KiBpg_math_16-1.1.0-1PGSTY.el9.aarch64.rpm
pg_math_161.1.0el10.x86_64pigsty72.8 KiBpg_math_16-1.1.0-1PGSTY.el10.x86_64.rpm
pg_math_161.1.0el10.aarch64pigsty71.3 KiBpg_math_16-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-math1.1.0d12.x86_64pigsty60.9 KiBpostgresql-16-pg-math_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-math1.1.0d12.aarch64pigsty60.0 KiBpostgresql-16-pg-math_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-math1.1.0d13.x86_64pigsty60.7 KiBpostgresql-16-pg-math_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-math1.1.0d13.aarch64pigsty60.1 KiBpostgresql-16-pg-math_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-math1.1.0u22.x86_64pigsty68.9 KiBpostgresql-16-pg-math_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-math1.1.0u22.aarch64pigsty67.9 KiBpostgresql-16-pg-math_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-math1.1.0u24.x86_64pigsty64.9 KiBpostgresql-16-pg-math_1.1.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-math1.1.0u24.aarch64pigsty63.8 KiBpostgresql-16-pg-math_1.1.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-math1.1.0u26.x86_64pigsty64.1 KiBpostgresql-16-pg-math_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-math1.1.0u26.aarch64pigsty63.4 KiBpostgresql-16-pg-math_1.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_math_151.1.0el8.x86_64pigsty70.9 KiBpg_math_15-1.1.0-1PGSTY.el8.x86_64.rpm
pg_math_151.1.0el8.aarch64pigsty69.3 KiBpg_math_15-1.1.0-1PGSTY.el8.aarch64.rpm
pg_math_151.1.0el9.x86_64pigsty72.9 KiBpg_math_15-1.1.0-1PGSTY.el9.x86_64.rpm
pg_math_151.1.0el9.aarch64pigsty70.9 KiBpg_math_15-1.1.0-1PGSTY.el9.aarch64.rpm
pg_math_151.1.0el10.x86_64pigsty72.9 KiBpg_math_15-1.1.0-1PGSTY.el10.x86_64.rpm
pg_math_151.1.0el10.aarch64pigsty71.3 KiBpg_math_15-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-math1.1.0d12.x86_64pigsty60.8 KiBpostgresql-15-pg-math_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-math1.1.0d12.aarch64pigsty60.0 KiBpostgresql-15-pg-math_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-math1.1.0d13.x86_64pigsty60.6 KiBpostgresql-15-pg-math_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-math1.1.0d13.aarch64pigsty60.3 KiBpostgresql-15-pg-math_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-math1.1.0u22.x86_64pigsty68.9 KiBpostgresql-15-pg-math_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-math1.1.0u22.aarch64pigsty67.9 KiBpostgresql-15-pg-math_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-math1.1.0u24.x86_64pigsty64.9 KiBpostgresql-15-pg-math_1.1.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-math1.1.0u24.aarch64pigsty63.8 KiBpostgresql-15-pg-math_1.1.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-math1.1.0u26.x86_64pigsty64.1 KiBpostgresql-15-pg-math_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-math1.1.0u26.aarch64pigsty63.4 KiBpostgresql-15-pg-math_1.1.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_math;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_math;		# install by package name

pig install pg_math -v 19;   # install for PG 19
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

Create 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-value
  • cdf_<distribution>_q(...) – cumulative distribution Q-value (1-P)
  • cdf_<distribution>_pinv(...) – inverse CDF P
  • cdf_<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=5

Table reader