Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
kfunc.h
Go to the documentation of this file.
1 /* The MIT License
2 
3  Copyright (C) 2010, 2013 Genome Research Ltd.
4  Copyright (C) 2011 Attractive Chaos <attractor@live.co.uk>
5 
6  Permission is hereby granted, free of charge, to any person obtaining
7  a copy of this software and associated documentation files (the
8  "Software"), to deal in the Software without restriction, including
9  without limitation the rights to use, copy, modify, merge, publish,
10  distribute, sublicense, and/or sell copies of the Software, and to
11  permit persons to whom the Software is furnished to do so, subject to
12  the following conditions:
13 
14  The above copyright notice and this permission notice shall be
15  included in all copies or substantial portions of the Software.
16 
17  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24  SOFTWARE.
25 */
26 
27 #ifndef HTSLIB_KFUNC_H
28 #define HTSLIB_KFUNC_H
29 
30 /* Log gamma function
31  * \log{\Gamma(z)}
32  * AS245, 2nd algorithm, http://lib.stat.cmu.edu/apstat/245
33  */
34 double kf_lgamma(double z);
35 
36 /* complementary error function
37  * \frac{2}{\sqrt{\pi}} \int_x^{\infty} e^{-t^2} dt
38  * AS66, 2nd algorithm, http://lib.stat.cmu.edu/apstat/66
39  */
40 double kf_erfc(double x);
41 
42 /* The following computes regularized incomplete gamma functions.
43  * Formulas are taken from Wiki, with additional input from Numerical
44  * Recipes in C (for modified Lentz's algorithm) and AS245
45  * (http://lib.stat.cmu.edu/apstat/245).
46  *
47  * A good online calculator is available at:
48  *
49  * http://www.danielsoper.com/statcalc/calc23.aspx
50  *
51  * It calculates upper incomplete gamma function, which equals
52  * kf_gammaq(s,z)*tgamma(s).
53  */
54 
55 double kf_gammap(double s, double z);
56 double kf_gammaq(double s, double z);
57 
58 /* Regularized incomplete beta function. The method is taken from
59  * Numerical Recipe in C, 2nd edition, section 6.4. The following web
60  * page calculates the incomplete beta function, which equals
61  * kf_betai(a,b,x) * gamma(a) * gamma(b) / gamma(a+b):
62  *
63  * http://www.danielsoper.com/statcalc/calc36.aspx
64  */
65 double kf_betai(double a, double b, double x);
66 
67 /*
68  * n11 n12 | n1_
69  * n21 n22 | n2_
70  * -----------+----
71  * n_1 n_2 | n
72  */
73 double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double *_right, double *two);
74 
75 #endif
double kf_betai(double a, double b, double x)
Definition: kfunc.c:172
double kf_gammaq(double s, double z)
Definition: kfunc.c:136
double kf_erfc(double x)
Definition: kfunc.c:54
double kf_lgamma(double z)
Definition: kfunc.c:35
double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double *_right, double *two)
Definition: kfunc.c:241
double kf_gammap(double s, double z)
Definition: kfunc.c:131