1 |
/* cdf/cdf_gamma.c |
/* cdf/cdf_gamma.c |
2 |
* |
* |
3 |
* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002 Gerard Jungman |
* Copyright (C) 2003 Jason Stover. |
|
* and Jason Stover. |
|
4 |
* |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
* 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 |
* it under the terms of the GNU General Public License as published by |
18 |
*/ |
*/ |
19 |
|
|
20 |
/* |
/* |
21 |
* Author: G. Jungman |
* Author: J. Stover |
|
* modified for gsl/cdf by J. Stover. |
|
22 |
*/ |
*/ |
23 |
|
|
24 |
#include <config.h> |
#include <config.h> |
53 |
} |
} |
54 |
else if ( x > 0.0 ) |
else if ( x > 0.0 ) |
55 |
{ |
{ |
56 |
tmp = 1.0-x*x; |
tmp = 1.0-x; |
57 |
val = (tmp+2*x*log(x))/(tmp*tmp); |
tmp *= tmp; |
58 |
|
val = (1.0-x*x+2*x*log(x))/tmp; |
59 |
return val; |
return val; |
60 |
} |
} |
61 |
else |
else |
63 |
return GSL_EDOM; |
return GSL_EDOM; |
64 |
} |
} |
65 |
} |
} |
66 |
static double gsl_cdf_norm_arg ( double x, double y ) |
static double gsl_cdf_norm_arg ( double x, double shape ) |
67 |
{ |
{ |
68 |
double val; |
double val; |
69 |
double tmp; |
double tmp; |
70 |
|
|
71 |
val = x + 1/3 - y - 0.2/y; |
val = x + 1/3 - shape - 0.02/shape; |
72 |
tmp = gsl_cdf_g ( (y-.5)/x); |
tmp = gsl_cdf_g ( (shape-.5)/x); |
73 |
if (tmp != GSL_EDOM ) |
if (tmp != GSL_EDOM ) |
74 |
{ |
{ |
75 |
val *= sqrt ( (1+tmp)/x); |
val *= sqrt ( (1+tmp)/x); |
95 |
{ |
{ |
96 |
return GSL_EDOM; |
return GSL_EDOM; |
97 |
} |
} |
98 |
|
if ( x <= 0.0 ) |
99 |
|
{ |
100 |
|
return 0.0; |
101 |
|
} |
102 |
y = x / scale; |
y = x / scale; |
103 |
if( shape < BIG_SHAPE ) |
if( shape < BIG_SHAPE ) |
104 |
{ |
{ |
133 |
{ |
{ |
134 |
return GSL_EDOM; |
return GSL_EDOM; |
135 |
} |
} |
136 |
|
if( x <= 0.0 ) |
137 |
|
{ |
138 |
|
return 1.0; |
139 |
|
} |
140 |
y = x / scale; |
y = x / scale; |
141 |
if ( shape < BIG_SHAPE ) |
if ( shape < BIG_SHAPE ) |
142 |
{ |
{ |