NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
kfunc.h
Go to the documentation of this file.
1 #ifndef __KFUNC_H__
2 #define __KFUNC_H__
3 
4 /* Log gamma function
5  * \log{\Gamma(z)}
6  * AS245, 2nd algorithm, http://lib.stat.cmu.edu/apstat/245
7  */
8 double kf_lgamma(double z);
9 
10 /* complementary error function
11  * \frac{2}{\sqrt{\pi}} \int_x^{\infty} e^{-t^2} dt
12  * AS66, 2nd algorithm, http://lib.stat.cmu.edu/apstat/66
13  */
14 double kf_erfc(double x);
15 
16 /* The following computes regularized incomplete gamma functions.
17  * Formulas are taken from Wiki, with additional input from Numerical
18  * Recipes in C (for modified Lentz's algorithm) and AS245
19  * (http://lib.stat.cmu.edu/apstat/245).
20  *
21  * A good online calculator is available at:
22  *
23  * http://www.danielsoper.com/statcalc/calc23.aspx
24  *
25  * It calculates upper incomplete gamma function, which equals
26  * kf_gammaq(s,z)*tgamma(s).
27  */
28 
29 double kf_gammap(double s, double z);
30 double kf_gammaq(double s, double z);
31 
32 /* Regularized incomplete beta function. The method is taken from
33  * Numerical Recipe in C, 2nd edition, section 6.4. The following web
34  * page calculates the incomplete beta function, which equals
35  * kf_betai(a,b,x) * gamma(a) * gamma(b) / gamma(a+b):
36  *
37  * http://www.danielsoper.com/statcalc/calc36.aspx
38  */
39 double kf_betai(double a, double b, double x);
40 
41 /*
42  * n11 n12 | n1_
43  * n21 n22 | n2_
44  * -----------+----
45  * n_1 n_2 | n
46  */
47 double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double *_right, double *two);
48 
49 #endif