3 * Binomial distribution
10 * float p, y, bdtrf();
12 * y = bdtrf( k, n, p );
18 * Returns the sum of the terms 0 through k of the Binomial
19 * probability density:
27 * The terms are not summed directly; instead the incomplete
28 * beta integral is employed, according to the formula
30 * y = bdtr( k, n, p ) = incbet( n-k, k+1, 1-p ).
32 * The arguments must be positive, with p ranging from 0 to 1.
38 * Relative error (p varies from 0 to 1):
39 * arithmetic domain # trials peak rms
40 * IEEE 0,100 2000 6.9e-5 1.1e-5
44 * message condition value returned
45 * bdtrf domain k < 0 0.0
52 * Complemented binomial distribution
59 * float p, y, bdtrcf();
61 * y = bdtrcf( k, n, p );
67 * Returns the sum of the terms k+1 through n of the Binomial
68 * probability density:
76 * The terms are not summed directly; instead the incomplete
77 * beta integral is employed, according to the formula
79 * y = bdtrc( k, n, p ) = incbet( k+1, n-k, p ).
81 * The arguments must be positive, with p ranging from 0 to 1.
87 * Relative error (p varies from 0 to 1):
88 * arithmetic domain # trials peak rms
89 * IEEE 0,100 2000 6.0e-5 1.2e-5
93 * message condition value returned
94 * bdtrcf domain x<0, x>1, n<k 0.0
98 * Inverse binomial distribution
105 * float p, y, bdtrif();
107 * p = bdtrf( k, n, y );
113 * Finds the event probability p such that the sum of the
114 * terms 0 through k of the Binomial probability density
115 * is equal to the given cumulative probability y.
117 * This is accomplished using the inverse beta integral
118 * function and the relation
120 * 1 - p = incbi( n-k, k+1, y ).
127 * Relative error (p varies from 0 to 1):
128 * arithmetic domain # trials peak rms
129 * IEEE 0,100 2000 3.5e-5 3.3e-6
133 * message condition value returned
134 * bdtrif domain k < 0, n <= k 0.0
143 Cephes Math Library Release 2.2: July, 1992
144 Copyright 1984, 1987, 1992 by Stephen L. Moshier
145 Direct inquiries to 30 Frost Street, Cambridge, MA 02140
151 float incbetf(float, float, float), powf(float, float);
152 float incbif( float, float, float );
154 float incbetf(), powf(), incbif();
158 float bdtrcf( int k, int n, float pp )
160 float bdtrcf( k, n, pp )
168 if( (p < 0.0) || (p > 1.0) )
176 mtherr( "bdtrcf", DOMAIN );
185 dk = 1.0 - powf( 1.0-p, dn );
190 dk = incbetf( dk, dn, p );
198 float bdtrf( int k, int n, float pp )
200 float bdtrf( k, n, pp )
208 if( (p < 0.0) || (p > 1.0) )
210 if( (k < 0) || (n < k) )
213 mtherr( "bdtrf", DOMAIN );
223 dk = powf( 1.0-p, dn );
228 dk = incbetf( dn, dk, 1.0 - p );
235 float bdtrif( int k, int n, float yy )
237 float bdtrif( k, n, yy )
245 if( (y < 0.0) || (y > 1.0) )
247 if( (k < 0) || (n <= k) )
250 mtherr( "bdtrif", DOMAIN );
257 p = 1.0 - powf( y, 1.0/dn );
262 p = 1.0 - incbif( dn, dk, y );