I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 1.00
sub units 9.86
+
0

CDF

Evaluates the negative binomial distribution CDF.
Controller: CodeCogs

Dependents

Info

Interface

C++

CDF

 
doubleCDFintk
intn
doublep
boolupper = false )
This function returns the lower and upper tails of the comulative negative binomial distribution function. The negative binomial distribution, also known as the Pascal distribution or Plya distribution, gives the probability of r-1 successes and x failures in x+r-1 trials, and success on the (x+r)th trial.

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

kthe maximum number of failures, must be >= 0
nthe number of sucesses
pthe probability of success for each trial, must be in range 0..1
upperDefault 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.