nbcdf(3f) - [M_datapac:CUMULATIVE_DISTRIBUTION] compute the negative binomial cumulative distribution function
Synopsis
Description
Note
Input Arguments
Output Arguments
Examples
Author
Maintainer
License
References
SUBROUTINE NBCDF(X,P,N,Cdf)
REAL(kind=wp),intent(in) :: X REAL(kind=wp),intent(in) :: P INTEGER :: N REAL(kind=wp),intent(out) :: Cdf
NBCDF(3f) computes the cumulative distribution function value at the REAL value X for the negative binomial distribution with REAL Bernoulli probability parameter = P, and integer
The negative binomial distribution used herein has mean = N*(1-P)/P and standard deviation = sqrt(N*(1-P)/(P*P))). this distribution is defined for all non-negative integer X-- X = 0, 1, 2, ... . This distribution has the probability function
f(X) = c(N+X-1,N) * P**N * (1-P)**XWhere c(N+X-1,N) is the combinatorial function equaling the number of combinations of N+X-1 items taken N at a time.
The negative binomial distribution is the distribution of the number of failures before obtaining N successes in an indefinite sequence of Bernoulli (0,1) trials where the probability of success in a precision trial = P.
Even though the input to this cumulative distribution function subroutine for this discrete distribution should (under normal circumstances) be a discrete integer value, the input variable X is REAL in mode.
X has been specified as REAL so as to conform with the datapac convention that all input ****data**** (as opposed to sample size, for example) variables to all datapac subroutines are REAL. This convention is based on the belief that
1. A mixture of modes (floating point versus integer) is inconsistent and an unnecessary complication in a data analysis; and 2. Floating point machine arithmetic (as opposed to integer arithmetic) is the more natural mode for doing data analysis.
X The value at which the cumulative distribution function is to be evaluated. X should be non-negative and integral-valued. P The value of the Bernoulli probability parameter for the negative binomial distribution. P should be between 0.0 (exclusively) and 1.0 (exclusively). N The integer value of the number of successes in Bernoulli trials parameter. N should be a positive integer.
CDF The cumulative distribution function value for the negative binomial distribution
Sample program:
program demo_nbcdf !@(#) line plotter graph of cumulative distribution function use M_datapac, only : nbcdf, plott, label implicit none real,allocatable :: x(:), y(:) real :: p integer :: i integer :: n call label(nbcdf) x=[(real(i),i=0,100,1)] if(allocated(y))deallocate(y) allocate(y(size(x))) p=0.50 n=size(x) do i=1,size(x) call NBCDF(X(i),P,N,y(i)) enddo call plott(x,y,size(x)) end program demo_nbcdfResults:
The following is a plot of Y(I) (vertically) versus X(I) (horizontally) I-----------I-----------I-----------I-----------I 0.1000000E+03 - X X X 0.9583334E+02 I X X X X 0.9166666E+02 I X X X X 0.8750000E+02 I XX X X 0.8333334E+02 I XXX X 0.7916667E+02 I XXXX 0.7500000E+02 - XXX 0.7083334E+02 I XX 0.6666667E+02 I XX 0.6250000E+02 I X 0.5833334E+02 I X 0.5416667E+02 I X 0.5000000E+02 - X 0.4583334E+02 I X 0.4166667E+02 I X 0.3750000E+02 I X 0.3333334E+02 I X 0.2916667E+02 I X 0.2500000E+02 - X 0.2083334E+02 I X 0.1666667E+02 I X 0.1250000E+02 I X 0.8333336E+01 I X 0.4166672E+01 I X 0.0000000E+00 - X I-----------I-----------I-----------I-----------I -0.1776E-14 0.1250E+00 0.2500E+00 0.3750E+00 0.5000E+00
The original DATAPAC library was written by James Filliben of the Statistical Engineering Division, National Institute of Standards and Technology.
John Urban, 2022.05.31
CC0-1.0
o National Bureau of Standards Applied Mathematics Series 55, 1964, page 945, Formulae 26.5.24 and 26.5.28, and page 929. o Johnson and Kotz, Discrete Distributions, 1969, pages 122-142, especially page 127. o Hastings and Peacock, Statistical Distributions--A Handbook for Students and Practitioners, 1975, pages 92-95. o Feller, an Introduction to Probability Theory and Its Applications, Volume 1, Edition 2, 1957, pages 155-157, 210. o Kendall and Stuart, the Advanced Theory of Statistics, Volume 1, Edition 2, 1963, pages 130-131. o Williamson and Bretherton, Tables of the Negative Binomial Probability Distribution, 1963. o Owen, Handbook of Statistical Tables, 1962, page 304.
Nemo Release 3.1 | nbcdf (3) | February 23, 2025 |