Calculates the negative binomial distribution PDF.

View versions (1)

Interface

#include <codecogs/statistics/distributions/discrete/negativebinomial/pdf.h>

using namespace Statistics::Distributions::Discrete::Negativebinomial;

The negative binomial distribution, also known as the Pascal distribution or Polya distribution, gives the probability of <em>r -1</em> successes and x failures in <em>x+r - 1</em> trials, and success on the <em>(x+r)</em> trial. The probability density is given by

P_{r,p} = \left ( \begin{array}{c}x+r-1\\r-1 \end{array} \right ) p^r (1-p)^x
(1)

where:

\left ( \begin{array}{c}x\\y \end{array} \right ) = \frac{x!}{(y! (x-y)!}
(2)

Example 1

#include <iostream>
#include <codecogs/stats/dists/discrete/negativebinomial/pdf.h>
using namespace Stats::Dists::Discrete::NegativeBinomial;

int main()
{
  std::cout << "\n PDF(10,5,0.25) = " << PDF(10, 5, 0.25);
  return 0;
}

Output:

PDF(10,5,0.25) = 0.0550487

Parameters

x
the number of failures
r
the threshold number of successes
p
the probability of success in each trial
GPL Licence — free for non commercial use. See Licence details.

Interactive Calculator

x
r
p
Result