10 |
* Cumulative Distribution Function Usage:: |
* Cumulative Distribution Function Usage:: |
11 |
* The gsl_cdf_result struct:: |
* The gsl_cdf_result struct:: |
12 |
* The Gaussian CDF:: |
* The Gaussian CDF:: |
13 |
|
* The Gamma CDF:: |
14 |
* CDF Examples:: |
* CDF Examples:: |
15 |
* CDF References and Further Reading:: |
* CDF References and Further Reading:: |
16 |
@end menu |
@end menu |
116 |
@end example |
@end example |
117 |
@end ifinfo |
@end ifinfo |
118 |
|
|
119 |
|
@page |
120 |
|
@node The Gamma CDF |
121 |
|
@section The Gamma Cumulative Distribution Function |
122 |
|
|
123 |
|
@deftypefun int gsl_cdf_gamma_e ( double @var{x}, double @var{scale}, double @var{shape}, gsl_cdf_tail_t @var{tail}, gsl_cdf_result @var{*result}) |
124 |
|
@deftypefun double gsl_cdf_gamma ( double @var{x}, double @var{scale}, double @var{shape}, gsl_cdf_tail_t @var{tail}) |
125 |
|
@end deftypefun |
126 |
|
|
127 |
|
These functions compute the probability @math{Pr(Z<x)} for a gamma |
128 |
|
random variable with scale parameter @var{scale} and shape parameter |
129 |
|
@var{shape} if @math{tail=GSL_CDF_LOWER}, or @math{Pr(Z>x)} if |
130 |
|
@math{tail=GSL_CDF_UPPER}. A random variable is said to follow the |
131 |
|
Gamma distribution with scale parameter @math{alpha} and shape |
132 |
|
parameter @math{beta} if |
133 |
|
@end deftypefun |
134 |
|
|
135 |
|
@tex |
136 |
|
\beforedisplay |
137 |
|
$$ |
138 |
|
Pr(Z<x) = { 1 \over alpha^{beta} \gamma{beta}} int_0^x t^{beta-1} \exp |
139 |
|
(t/alpha) dt |
140 |
|
$$ |
141 |
|
@end tex |
142 |
|
@ifinfo |
143 |
|
@example |
144 |
|
Pr(Z<x) = @{ 1 \over alpha^@{beta@} \gamma@{beta@}@} int_0^x t^@{beta-1@} \exp |
145 |
|
(t/alpha) dt |
146 |
|
@end example |
147 |
|
@end ifinfo |
148 |
|
|
149 |
|
The Chi-square distribution with @math{n} degrees of freedom |
150 |
|
is a special case of the Gamma distribution with shape parameter |
151 |
|
@math{n/2} and scale parameter @math{2}. |
152 |
|
|
153 |
|
The Gamma distribution is sometimes called the Erlang distribution in |
154 |
|
queueing theory. |
155 |
|
|
156 |
@node CDF Examples |
@node CDF Examples |
157 |
@section Examples |
@section Examples |
158 |
|
|
218 |
Chance that Z is greater than 1.500000 is 0.066807. |
Chance that Z is greater than 1.500000 is 0.066807. |
219 |
@end example |
@end example |
220 |
|
|
221 |
|
|
222 |
|
@noindent |
223 |
|
The following program computes different values from the |
224 |
|
Gamma distribution with shape parameter 2.3 and scale parameter 1.2. |
225 |
|
|
226 |
|
@example |
227 |
|
#include <math.h> |
228 |
|
#include <gsl/gsl_cdf.h> |
229 |
|
#include <gsl/gsl_cdf_result.h> |
230 |
|
#include <gsl/gsl_errno.h> |
231 |
|
int main() |
232 |
|
@{ |
233 |
|
gsl_cdf_result result; |
234 |
|
double y; |
235 |
|
double shape = 2.3; |
236 |
|
double scale = 1.2; |
237 |
|
int rc = 0; |
238 |
|
|
239 |
|
for ( y = -.5; y < 5.3; y += .02 ) |
240 |
|
@{ |
241 |
|
rc = gsl_cdf_gamma_e ( y, scale, shape, GSL_CDF_UPPER, &result |
242 |
|
); |
243 |
|
if ( rc == GSL_SUCCESS ) |
244 |
|
@{ |
245 |
|
printf ( "%f\n",result.val); |
246 |
|
@} |
247 |
|
@} |
248 |
|
return rc; |
249 |
|
@} |
250 |
|
|
251 |
|
This program can be compiled and run in the same way as that of the |
252 |
|
previous example. |
253 |
|
@end example |
254 |
|
|
255 |
@node CDF References and Further Reading |
@node CDF References and Further Reading |
256 |
@section References and Further Reading |
@section References and Further Reading |
257 |
@noindent |
@noindent |