Category : C Source Code
Archive   : CEPHES22.ZIP
Filename : NBDTR.C

 
Output of file : NBDTR.C contained in archive : CEPHES22.ZIP
/* nbdtr.c
*
* Negative binomial distribution
*
*
*
* SYNOPSIS:
*
* int k, n;
* double p, y, nbdtr();
*
* y = nbdtr( k, n, p );
*
*
*
* DESCRIPTION:
*
* Returns the sum of the terms 0 through k of the negative
* binomial distribution:
*
* k
* -- ( n+j-1 ) n j
* > ( ) p (1-p)
* -- ( j )
* j=0
*
* In a sequence of Bernoulli trials, this is the probability
* that k or fewer failures precede the nth success.
*
* The terms are not computed individually; instead the incomplete
* beta integral is employed, according to the formula
*
* y = nbdtr( k, n, p ) = incbet( n, k+1, p ).
*
* The arguments must be positive, with p ranging from 0 to 1.
*
*
*
* ACCURACY:
*
* See incbet.c.
*
*/
/* nbdtrc.c
*
* Complemented negative binomial distribution
*
*
*
* SYNOPSIS:
*
* int k, n;
* double p, y, nbdtrc();
*
* y = nbdtrc( k, n, p );
*
*
*
* DESCRIPTION:
*
* Returns the sum of the terms k+1 to infinity of the negative
* binomial distribution:
*
* inf
* -- ( n+j-1 ) n j
* > ( ) p (1-p)
* -- ( j )
* j=k+1
*
* The terms are not computed individually; instead the incomplete
* beta integral is employed, according to the formula
*
* y = nbdtrc( k, n, p ) = incbet( k+1, n, 1-p ).
*
* The arguments must be positive, with p ranging from 0 to 1.
*
*
*
* ACCURACY:
*
* See incbet.c.
*
*/

/*
Cephes Math Library Release 2.0: April, 1987
Copyright 1984, 1987 by Stephen L. Moshier
Direct inquiries to 30 Frost Street, Cambridge, MA 02140
*/

#include "mconf.h"

double nbdtrc( k, n, p )
int k, n;
double p;
{
double dk, dn;
double incbet();

if( (p < 0.0) || (p > 1.0) )
goto domerr;
if( k < 0 )
{
domerr:
mtherr( "nbdtr", DOMAIN );
return( 0.0 );
}

dk = k+1;
dn = n;
return( incbet( dk, dn, 1.0 - p ) );
}



double nbdtr( k, n, p )
int k, n;
double p;
{
double dk, dn;
double incbet();

if( (p < 0.0) || (p > 1.0) )
goto domerr;
if( k < 0 )
{
domerr:
mtherr( "nbdtr", DOMAIN );
return( 0.0 );
}
dk = k+1;
dn = n;
return( incbet( dn, dk, p ) );
}


  3 Responses to “Category : C Source Code
Archive   : CEPHES22.ZIP
Filename : NBDTR.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/