math.special
factorials of any number, bell curve areas and logistic curves, plus step, ramp and pulse shapes
Functions that come up in statistics, probability and signal processing. They include the factorial extended to any number, and the area under the bell curve.
Tags: numbers
gammathe gamma function, which extends the factorial: gamma(n + 1) is n!, and it works between whole numbers toolgammathe natural log of the gamma function, which stays finite where gamma itself is too largebetathe beta function, gamma(a) × gamma(b) / gamma(a + b)erfthe error function: the chance a normal variable lands within x√2 standard deviations of its meanerfcthe complementary error function, 1 - erf(x), accurate even where that would round to 0digammathe digamma function, the slope of lgamma: the derivative of ln(gamma(x))zetathe Riemann zeta function, the sum of 1 / n^s over every whole number n from 1erf_invthe inverse of the error function: the x where erf(x) is y, for y between -1 and 1probitthe normal quantile: the z where a standard normal variable falls below z with chance pgamma_incthe regularized lower incomplete gamma function: the share of gamma(a) accumulated up to x, from 0 to 1beta_incthe regularized incomplete beta function: the share of beta(a, b) accumulated up to x, for x from 0 to 1sigmoidthe logistic curve 1 / (1 + e^-x): an S shape from 0 to 1logitthe inverse of sigmoid, ln(p / (1 - p)), for p between 0 and 1heavisidethe step function: 0 below zero, 1 above, and 1/2 at zerorampthe ramp function: 0 below zero, and x aboverectthe rectangle pulse: 1 for x within 1/2 of zero, 1/2 at the edges, 0 beyondtrithe triangle pulse: 1 at zero, falling in straight lines to 0 at 1 and -1
Functions
Section titled “Functions”gamma(x: num) -> float
the gamma function, which extends the factorial: gamma(n + 1) is n!, and it works between whole numbers too
1gamma(5)242gamma(0.5) ** 23.14159See also lgamma, beta, factorial
lgamma
Section titled “lgamma”lgamma(x: num) -> float
the natural log of the gamma function, which stays finite where gamma itself is too large
1lgamma(1000)5905.22See also gamma
beta(a: num, b: num) -> float
the beta function, gamma(a) × gamma(b) / gamma(a + b)
1beta(2, 3)0.0833333See also gamma
erf(x: num) -> float
the error function: the chance a normal variable lands within x√2 standard deviations of its mean
1erf(1)0.8427012erf(1 / sqrt(2))0.682689See also erfc
erfc(x: num) -> float
the complementary error function, 1 - erf(x), accurate even where that would round to 0
1erfc(1)0.1572992erfc(5)1.53746e-12See also erf
digamma
Section titled “digamma”digamma(x: num) -> float
the digamma function, the slope of lgamma: the derivative of ln(gamma(x))
1digamma(1)-0.5772162digamma(0.5)-1.96351zeta(s: num) -> float
the Riemann zeta function, the sum of 1 / n^s over every whole number n from 1
1zeta(2)1.644932zeta(0.5)-1.46035See also gamma
erf_inv
Section titled “erf_inv”erf_inv(y: num) -> float
the inverse of the error function: the x where erf(x) is y, for y between -1 and 1
1erf_inv(0.5)0.4769362erf(erf_inv(0.3))0.3probit
Section titled “probit”probit(p: num) -> float
the normal quantile: the z where a standard normal variable falls below z with chance p
1probit(0.975)1.959962probit(0.5)0See also erf_inv
gamma_inc
Section titled “gamma_inc”gamma_inc(a: num, x: num) -> float
the regularized lower incomplete gamma function: the share of gamma(a) accumulated up to x, from 0 to 1
1gamma_inc(1, 2)0.8646652gamma_inc(3, 3)0.57681beta_inc
Section titled “beta_inc”beta_inc(x: num, a: num, b: num) -> float
the regularized incomplete beta function: the share of beta(a, b) accumulated up to x, for x from 0 to 1
1beta_inc(0.5, 2, 2)0.52beta_inc(0.25, 1, 3)0.578125sigmoid
Section titled “sigmoid”sigmoid(x: num) -> float
the logistic curve 1 / (1 + e^-x): an S shape from 0 to 1
1sigmoid(0)0.52sigmoid(2)0.880797See also logit
logit(p: num) -> float
the inverse of sigmoid, ln(p / (1 - p)), for p between 0 and 1
1logit(0.5)02logit(sigmoid(2))2See also sigmoid
heaviside
Section titled “heaviside”heaviside(x: num) -> float
the step function: 0 below zero, 1 above, and 1/2 at zero
1heaviside(-2)02heaviside(3)1ramp(x: num) -> float
the ramp function: 0 below zero, and x above
1ramp(-2)02ramp(3)3See also heaviside
rect(x: num) -> float
the rectangle pulse: 1 for x within 1/2 of zero, 1/2 at the edges, 0 beyond
1rect(0.2)12rect(1)0tri(x: num) -> float
the triangle pulse: 1 at zero, falling in straight lines to 0 at 1 and -1
1tri(0.25)0.752tri(2)0See also rect
More examples
Section titled “More examples”special
Section titled “special”1# the factorial of 4.52gamma(5.5)52.34283# the share of a normal distribution within 1.96 standard deviations4erf(1.96 / sqrt(2))0.9500045# an S-shaped curve from 0 to 16sigmoid(2)0.880797Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.