Scryer Prolog

Module special_functions

:- use_module(library(numerics/special_functions)).

Special math functions in the Error, Gamma and Beta families

The underlying Rust implementations come from the puruspe crate.

erf(+Xexpr, -Erf)

X is Xexpr ∈ ℝ, Erf is erf(X).

DLMF §7.2.1, puruspe::error::erf

erfc(+X, -Erfc)

Erfc is erfc(X) for X ∈ ℝ.

DLMF §7.2.2, puruspe::error::erfc

inverf(+ErfX, -X)

X is erf⁻¹(ErfX) for ErfX ∈ (-1,1).

inverfc(+ErfcX, -X)

X is erfc⁻¹(ErfcX) for ErfcX ∈ (0,2).

gamma(+X, -Gamma)

Gamma is Γ(X), the [ordinary] gamma function evaluated at X ∈ ℝ.

DLMF §5.2.1 puruspe::gamma::gamma

gamma(+A, +X, -Gamma)

Gamma is Γ(A,X), the upper incomplete gamma function, where A > 0 is the shape parameter and X ≥ 0 is the lower limit of integration.

DLMF §8.2.2,

gamma_P_Q(+A, +X, -P, -Q)

For shape parameter A > 0 and lower limit of integration X ≥ 0,

  • P is γ(A,X)/Γ(X), the regularized lower incomplete gamma function, and

  • Q is Γ(A,X)/Γ(X), the regularized upper incomplete gamma function.

DLMF §8.2.4, puruspe::gammp::gammp, puruspe::gammp::gammq

invgammp(+A, +P, -X)

Given shape parameter A > 0 and probability P ∈ [0,1),

X is the unique solution of P = P(A,X), where P(-,-) is the regularized lower incomplete gamma function.

puruspe::gamma::invgammp

log_gamma(+X, -LogGamma)

LogGamma is ln(Γ(X)), the natural logarithm of Γ(X).

puruspe::gamma::ln_gamma

beta(+X, +Y, -B)

B is B(X,Y) ≡ Γ(X)*Γ(Y)/Γ(X+Y)

DLMF §5.12.1 puruspe::beta::beta

betai(+A, +B, +X, -Ix)

Given:

  • shape parameters A > 0 and B > 0,

  • upper limit of integration X ∈ [0,1],

Ix is Iₓ(A,B) ≡ B(X;A,B)/B(A,B), the regularized incomplete beta function;

DLMF §8.17.2, puruspe::beta::betai

invbetai(+A, +B, +P, -X)

Given:

  • shape parameters A > 0 and B > 0,

  • probability P ∈ [0,1],

X ∈ [0,1] is the unique solution of P = Iₓ(A,B) ≡ B(X;A,B)/B(A,B).

puruspe::beta::invbetai

test_special_functions

Run all tests defined in this module. (These tests succeed when they find counterexamples, so the 'desirable' result is false.)

test(+Name, ?Goal)

Tests have the signature established by @bakaq's testframework, each with a user-facing string Name, and a Goal which serves as an _assertion by succeeding iff the Name'd desirable property holds.

try_falsify/1

witness/1