CDF
Evaluates the negative binomial distribution CDF.
Controller: CodeCogs
Contents
Dependents
Interface
C++
CDF
doubleCDF( | int | k | |
int | n | ||
double | p | ||
bool | upper = false | ) |
Example:
#include <stdio.h> #include <codecogs/statistics/distributions/discrete/negativebinomial/cdf.h> using namespace Stats::Dists::Discrete::NegativeBinomial; int main() { int k[10] = { 1, 3, 0, 5, 6, 5, 1, 5, 6, 3 }; int n[10] = { 4, 3, 8, 1, 2, 4, 9, 5, 1, 2 }; double p[10] = { 0.4, 0.1, 0.7, 0.2, 0.3, 0.6, 0.2, 0.7, 0.3, 0.2 }; for( int i=0; i<10; i++ ) printf( "CDF( %i, %i, %1.1f, true ) = %f \n", k[i], n[i], p[i], CDF(k[i],n[i],p[i],true) ); return getchar(); }
Output:
CDF( 1, 4, 0.4, true ) = 0.912960 CDF( 3, 3, 0.1, true ) = 0.984150 CDF( 0, 8, 0.7, true ) = 0.942352 CDF( 5, 1, 0.2, true ) = 0.262144 CDF( 6, 2, 0.3, true ) = 0.255298 CDF( 5, 4, 0.6, true ) = 0.099353 CDF( 1, 9, 0.2, true ) = 0.999996 CDF( 5, 5, 0.7, true ) = 0.047349 CDF( 6, 1, 0.3, true ) = 0.082354 CDF( 3, 2, 0.2, true ) = 0.737280
Accuracy:
Tested at random points (a,b,p) with p between 0 and 1. a,b domain # trials peak rms 0,100 100000 1.7e-13 8.8e-15
Parameters
k the maximum number of failures, must be >= 0 n the number of sucesses p the probability of success for each trial, must be in range 0..1 upper Default value = false
Returns
- the probability that more than k failures precede the nth success in a sequence of Bernoulli trials.
Authors
- Stephen L. Moshier (June 2000)
Updated by Vince Cole (April 2005)
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.