staticdouble big = 4.503599627370496e15; staticdouble biginv = 2.22044604925031308085e-16;
double incbet(aa, bb, xx) double aa, bb, xx;
{ double a, b, t, x, xc, w, y; int flag;
if (aa <= 0.0 || bb <= 0.0) goto domerr;
if ((xx <= 0.0) || (xx >= 1.0)) { if (xx == 0.0) return (0.0); if (xx == 1.0) return (1.0);
domerr:
mtherr("incbet", DOMAIN); return (0.0);
}
flag = 0; if ((bb * xx) <= 1.0 && xx <= 0.95) {
t = pseries(aa, bb, xx); goto done;
}
w = 1.0 - xx;
/* Reverse a and b if x is greater than the mean. */ if (xx > (aa / (aa + bb))) {
flag = 1;
a = bb;
b = aa;
xc = xx;
x = w;
} else {
a = aa;
b = bb;
xc = w;
x = xx;
}
if (flag == 1 && (b * x) <= 1.0 && x <= 0.95) {
t = pseries(a, b, x); goto done;
}
/* Choose expansion for better convergence. */
y = x * (a + b - 2.0) - (a - 1.0); if (y < 0.0)
w = incbcf(a, b, x); else
w = incbd(a, b, x) / xc;
/* Multiply w by the factor ab___
x (1-x) | (a+b) / ( a | (a) | (b) ) . */
y = a * log(x);
t = b * log(xc); if ((a + b) < MAXGAM && fabs(y) < MAXLOG && fabs(t) < MAXLOG) {
t = pow(xc, b);
t *= pow(x, a);
t /= a;
t *= w;
t *= gamma(a + b) / (gamma(a) * gamma(b)); goto done;
} /* Resort to logarithms. */
y += t + lgam(a + b) - lgam(a) - lgam(b);
y += log(w / a); if (y < MINLOG)
t = 0.0; else
t = exp(y);
done:
if (flag == 1) { if (t <= MACHEP)
t = 1.0 - MACHEP; else
t = 1.0 - t;
} return (t);
}
/* Continued fraction expansion #1 *forincompletebetaintegral
*/
/* Power series for incomplete beta integral.
Use when b*x is small and x not too close to 1. */
staticdouble pseries(a, b, x) double a, b, x;
{ double s, t, u, v, n, t1, z, ai;
ai = 1.0 / a;
u = (1.0 - b) * x;
v = u / (a + 1.0);
t1 = v;
t = u;
n = 2.0;
s = 0.0;
z = MACHEP * ai; while (fabs(v) > z) {
u = (n - b) * x / n;
t *= u;
v = t / (a + n);
s += v;
n += 1.0;
}
s += t1;
s += ai;
u = a * log(x); if ((a + b) < MAXGAM && fabs(u) < MAXLOG) {
t = gamma(a + b) / (gamma(a) * gamma(b));
s = s * t * pow(x, a);
} else {
t = lgam(a + b) - lgam(a) - lgam(b) + u + log(s); if (t < MINLOG)
s = 0.0; else
s = exp(t);
} return (s);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.