Debian Codegraph @

external/gsl/gsl_cdf__gamma.c

raw symbols SCIP
1 /* cdf/cdf_gamma.c
2 *
3 * Copyright (C) 2003 Jason Stover.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 /*
21 * Author: J. Stover
22 */
23
24 #include "gsl__config.h"
25 #include <math.h>
26 #include "gsl_cdf.h"
27 #include "gsl_math.h"
28 #include "gsl_sf_gamma.h"
29
30 double
31 gsl_cdf_gamma_P (const double x, const double a, const double b)
32 {
33 double P;
34 double y = x / b;
35
36 if (x <= 0.0)
37 {
38 return 0.0;
39 }
40
41 if (y > a)
42 {
43 P = 1 - gsl_sf_gamma_inc_Q (a, y);
44 }
45 else
46 {
47 P = gsl_sf_gamma_inc_P (a, y);
48 }
49
50 return P;
51 }
52
53 double
54 gsl_cdf_gamma_Q (const double x, const double a, const double b)
55 {
56 double Q;
57 double y = x / b;
58
59 if (x <= 0.0)
60 {
61 return 1.0;
62 }
63
64 if (y < a)
65 {
66 Q = 1 - gsl_sf_gamma_inc_P (a, y);
67 }
68 else
69 {
70 Q = gsl_sf_gamma_inc_Q (a, y);
71 }
72
73 return Q;
74 }