# Negative Binomial Distribution

Page Contents

## Negative Binomial Distribution

Conduct a sequence of independent Bernoulli trials , with probability ~p of success on each trial until we obtain a pre-defined number ~r of successes. What is the probability of exactly ~x failures before getting the ~r successes? Such a random variable is said to have a #~{negative binomial distribution}:

P ( ~X = ~x ) _ = _ ~p^{~r} comb{-~r,~x} ({-1})^~x ( 1 - ~p )^~x , _ _ ~x >= 0

where

comb{-~r,~x} _ _ #:= _ _ fract{-~r ( -~r - 1 ) ... ( -~r - ~x + 1 ),~x#! }

_ _ _ _ _ _ _ _ _ = _ ({-1})^~x fract{~r ( ~r + 1 ) ... ( ~r + ~x - 1 ),~x#! }

_ _ _ _ _ _ _ _ _ = _ ({-1})^~x comb{ ~r + ~x - 1 ,~x }

So we can write the alternative form

P ( ~X = ~x ) _ = _ ( ^{~r +}_~x^{~x - 1} ) ~p^{~r} ( 1 - ~p ) ^~x , _ _ ~x >= 0

Note Taylor series expansion: _ ( 1 - ~t )^{-~r} _ = _ &sum._0^{&infty.} ( ^-_~x^~r ) ( -~t ) ^~x .
So _ &sum. ~p^~r ( ^-_~x^~r ) ( -1 ) ^~x ( 1 - ~p ) ^~x _ = _ ~p^~r &sum. ( ^-_~x^~r ) ( - ( 1 - ~p ) ) ^~x _ = _ ~p^~r ~p^{-~r} _ = _ 1

## Alternative Definition

Consider the total number of trials to get ~r successes, let this be the random variable ~Y, then ~Y = ~X + ~r, and

P ( ~Y = ~y ) _ = _ P ( ~X = ~y - ~r )

_ _ _ _ _ _ _ _ _ = _ ( ^~y_~y^-_-^1_~r ) ~p^{~r} ( 1 - ~p ) ^{~y - ~r}

_ _ _ _ _ _ _ _ _ = _ ( ^~y_~r^-_-^1_1 ) ~p^{~r} ( 1 - ~p ) ^{~y - ~r} , _ _ ~y >= ~r

Which is also sometimes called the negative binomial

## Moments

The p.g.f. of the Negative Binomial Distribution is given by

&Phi.( ~t ) _ = _ sum{~p^{~r} comb{-~r,~x} ({-1}) ^~x ( 1 - ~p ) ^~x ~t ^~x,~x = 0,&infty.}

_ _ _ _ _ _ _ _ = _ ~p^{~r} sum{ comb{-~r,~x} ( -~t ( 1 - ~p ) ) ^~x,~x = 0,&infty.}

_ _ _ _ _ _ _ _ = _ script{rndb{fract{~p,( 1 - ~t ( 1 - ~p ))}},,,~r,}

&Phi.'( ~t ) _ = _ fract{~r ~p^~r ( 1 - ~p ),( 1 - ~t ( 1 - ~p ) ) ^{~r + 1}}

&Phi.''( ~t ) _ = _ fract{( ~r + 1 ) ~r ~p^~r ( 1 - ~p )^2,( 1 - ~t ( 1 - ~p ) ) ^{~r + 2}}

&Phi.'( 1 ) _ = _ fract{~r ( 1 - ~p ), _ ~p _ }

&Phi.''( 1 ) _ = _ fract{( ~r + 1 ) ~r ( 1 - ~p )^2, _ ~p ^2 _ }

E( ~X ) _ = _ fract{~r ( 1 - ~p ), _ ~p _ }

var( ~X ) _ = _ fract{( ~r + 1 ) ~r ( 1 - ~p )^2 _ + _ ~r ~p ( 1 - ~p ) _ - _ ~r ^2 ( 1 - ~p ) ^2, _ ~p ^2 _ }

_ _ _ _ _ _ _ _ _ = _ fract{~r ( 1 - ~p ), _ ~p ^2 _ }

 E( ~X ) _ = _ {~r ( 1 - ~p ) ./ ~p } var( ~X ) _ = _ {~r ( 1 - ~p ) ./ ~p ^2 }