24double gammaIncSeries(
double a,
double x);
25double gammaIncCFrac(
double a,
double x);
27#define GAMMAI_ACCURACY 1e-12
47 return gammaIncSeries(a, x);
50 return 1 - gammaIncCFrac(a, x);
71 return 1 - gammaIncSeries(a, x);
74 return gammaIncCFrac(a, x);
78#define MAX_SERIES 1000
80double gammaIncSeries(
double a,
double x) {
84 fprintf(stderr,
"lgamma function not implemented in vxWorks");
87 term = exp(-x) * pow(x, a) / exp(lgamma(a + 1));
95 }
while (term > GAMMAI_ACCURACY && n < MAX_SERIES);
99double gammaIncCFrac(
double a,
double x) {
100 double A0, B0, A1, B1, A_1, B_1;
101 double an, bn, f1, f2, accuracy = 0, factor = 0;
105 fprintf(stderr,
"lgamma function not implemented in vxWorks");
108 accuracy = GAMMAI_ACCURACY / (factor = exp(-x - lgamma(a) + a * log(x)));
116 A1 = bn * A0 + an * A_1;
117 B1 = bn * B0 + an * B_1;
128 A1 = bn * A0 + an * A_1;
129 B1 = bn * B0 + an * B_1;
139 }
while (m < MAX_SERIES && fabs(f1 - f2) > accuracy);
double gammaP(double a, double x)
Compute the regularized lower incomplete gamma function P(a,x).
double gammaQ(double a, double x)
Compute the regularized upper incomplete gamma function Q(a,x).