For statistical
calculations, you will need use special functions for cumulative distributions, such as the cumulative standard normal distribution or the cumulative Student's t distribution.
The transcendental package, described below, is an extension module that gives access to the special functions available in Cephes. For reasons of portability, this extension module is written in ANSI-C; its compilation should therefore be straightforward.
It compiled out of the box on the following systems:
The transcendental module contains an extensive collection of special functions, listed below.
>>> from transcendental import *
>>> ndtr(2.) - ndtr(-2.)
0.95449973610364158
About 95% of the normal distribution is contained with 2 standard deviations from the mean.
>>> ndtri(0.025)
-1.9599639845400545
For a two-sided test, you need a Z-score of about 1.96 (in absolute value) for a statistically significant result at α = 5%.
>>> x = array([2.6, 2.1, 1.2, 3.9, -0.3])
>>> n = len(x)
>>> m = sum(x)/n
>>> m
1.8999999999999999
>>> s = sqrt(sum((x-m)**2)/(n-1))
>>> t = m*sqrt(n)/s
>>> t
2.7060146365054543
>>> p = stdtr(n-1,t)
>>> p
0.97312075603186332
In a one-sided t-test, this result is significant at α = 5%; in a two-sided t-test, it is not.
cbrt(x): Cube rooterf(x): Error function
erfc(x): Complementary error function
ndtr(x): Cumulative standard normal distribution
ndtri(p): Inverse of the cumulative normal distribution
fac(i): Factorial function
bdtr(k,n,p): Cumulative binomial probability density
bdtrc(k,n,p): Complemented binomial distribution
bdtri(k,n,y): Inverse binomial distribution
nbdtr(k,n,p): Cumulative negative binomial probability density
nbdtrc(k,n,p): Complemented cumulative negative binomial distribution
nbdtri(k,n,y): Inverse of the cumulative negative binomial distribution
gdtr(a,b,x): Cumulative gamma probability density
gdtrc(a,b,x): Complemented cumulative gamma distribution function
pdtr(k,m): Cumulative Poisson distribution
pdtrc(k,m): Complemented cumulative Poisson distribution
pdtri(k,p): Inverse of the cumulative Poisson distribution
beta(a,b): Beta function
igam(a,x): Incomplete gamma integral
igamc(a,x): Complemented incomplete gamma integral
igami(a,p): Inverse of the complemented incomplete gamma integral
incbet(a,b,x): Incomplete beta integral
incbi(a,b,y): Inverse of the incomplete beta integral
fresnl(x): Fresnel cosine and sine integrals
stdtr(k,t): Cumulative Student's t distribution
stdtri(k,p): Inverse of the cumulative Student's t distribution
chdtr(v,x): Cumulative chi square distribution
chdtrc(v,x): Complemented cumulative chi square distribution
chdtri(v,p): Inverse of the complemented cumulative chi square distribution.
fdtr(a,b,x): Cumulative F distribution
fdtrc(a,b,x): Complemented cumulative F distribution
fdtri(a,b,p): Inverse of the complemented cumulative F distribution
gamma(x): Gamma function
lgamma(x): Natural logarithm of gamma function
rgamma(x): Reciprocal gamma function
psi(x): Psi (digamma) function
dawsn(x): Dawson's integral
j0(x): Bessel function of order 0j1(x): Bessel function of order 1jn(n,x): Bessel function of integer order njv(v,x): Bessel function of noninteger order vy0(x): Bessel function of the second kind, order 0y1(x): Bessel function of the second kind, order 1yn(n,x): Bessel function of the second kind, integer order nyv(v,x): Bessel function of the second kind, noninteger order vi0(x): Modified Bessel function, order 0i0e(x): Modified Bessel function, order 0, exponentially scaledi1(x): Modified Bessel function, order 1i1e(x): Modified Bessel function, order 1, exponentially scalediv(v,x): Modified Bessel function, order vk0(x): Modified Bessel function, third kind, order 0k0e(x): Modified Bessel function, third kind, order 0, exponentially scaledk1(x): Modified Bessel function, third kind, order 1k1e(x): Modified Bessel function, third kind, order 1, exponentially scaledkn(n,x): Modified Bessel function, third kind, order nairy(x): Airy functionexpn(n, x): Exponential integralshichi(x): Hyperbolic sine and cosine integralssici(x): Sine and cosine integralshyperg(a, b, x): Confluent hypergeometric functionhyp2f1(a, b, c, x): Gauss hypergeometric functionellpk(m1): Complete elliptic integral of the first kindellik(phi, m): Incomplete elliptic integral of the first kindellpe(x): Complete elliptic integral of the second kindellpe(phi, m): Incomplete elliptic integral of the second kindellpj(u, m): Jacobian Elliptic functionsspence(x): Dilogarithmzeta(x, q): Riemann zeta function of two argumentszetac(x): Riemann zeta functionstruve(v, x): Struve functionpython setup.py configconfig.h, which is used in the subsequent build step.config.h files that were generated by running python setup.py config on various platforms:
python setup.py build
python setup.py install