Using Python to solve problems in bioinformatics

Special functions

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.

Usage examples

>>> 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.

List of available functions

Installation

On Windows, you can use the binary installer. On all other platforms, you can compile the module in three steps:
transcendental-0.10.tar.gz (source distribution)
transcendental-0.10.win32-py2.5.exe (windows installer for Python 2.5)
transcendental-0.10.win32-py2.6.exe (windows installer for Python 2.6)
transcendental-0.10.win32-py2.7.exe (windows installer for Python 2.7)







Back to home page