Previous: Hypergeometric Random Variable, Up: Functions and Variables for discrete distributions   [Contents][Index]

52.3.8 Negative Binomial Random Variable

The negative binomial distribution is a discrete probability distribution. Suppose we have a sequence of Bernoulli trials where each trial has two outcomes called “success” and “failure” where “success” occurs with probablity p and “failure” with probability 1-p. We observe the sequence until a predefined number r of sucesses have occurred. Then the number of failures seen will have a \({\it NegativeBinomial}(r,p)\) distribution.

Function: pdf_negative_binomial (x,n,p)

Returns the value at x of the probability function of a \({\it NegativeBinomial}(n,p)\) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

The pdf is $$ f(x; n, p) = {x+n-1 \choose n-1} (1-p)^xp^n $$

Categories:Package distrib ·
Function: cdf_negative_binomial (x,n,p)

Returns the value at x of the distribution function of a \({\it NegativeBinomial}(n,p)\) random variable, with 0 < p \leq 1 and n a positive number.

The cdf is $$ F(x; n, p) = I_p(n,\lfloor x \rfloor + 1) $$

where \(I_p(a,b)\) is the beta_incomplete_regularized function.

(%i1) load ("distrib")$
(%i2) cdf_negative_binomial(3,4,1/8);
                              3271
(%o2)                        ------
                             524288
Categories:Package distrib ·
Function: quantile_negative_binomial (q,n,p)

Returns the q-quantile of a \({\it NegativeBinomial}(n,p)\) random variable, with 0 < p \leq 1 and n a positive number; in other words, this is the inverse of cdf_negative_binomial. Argument q must be an element of [0,1]. To make use of this function, write first load("distrib").

Categories:Package distrib ·
Function: mean_negative_binomial (n,p)

Returns the mean of a \({\it NegativeBinomial}(n,p)\) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

The mean is $$ E[X] = {n(1-p)\over p} $$

Categories:Package distrib ·
Function: var_negative_binomial (n,p)

Returns the variance of a \({\it NegativeBinomial}(n,p)\) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

The variance is $$ V[X] = {n(1-p)\over p^2} $$

Categories:Package distrib ·
Function: std_negative_binomial (n,p)

Returns the standard deviation of a \({\it NegativeBinomial}(n,p)\) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

The standard deviation is $$ D[X] = {\sqrt{n(1-p)}\over p} $$

Categories:Package distrib ·
Function: skewness_negative_binomial (n,p)

Returns the skewness coefficient of a \({\it NegativeBinomial}(n,p)\) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

The skewness coefficient is $$ SK[X] = {2-p \over \sqrt{n(1-p)}} $$

Categories:Package distrib ·
Function: kurtosis_negative_binomial (n,p)

Returns the kurtosis coefficient of a \({\it NegativeBinomial}(n,p)\) random variable, with 0 < p \leq 1 and n a positive number. To make use of this function, write first load("distrib").

The kurtosis coefficient is $$ KU[X] = {p^2-6p+6 \over n(1-p)} $$

Categories:Package distrib ·
Function: random_negative_binomial (n,p)
    random_negative_binomial (n,p,m)

Returns a \({\it NegativeBinomial}(n,p)\) random variate, with 0 < p \leq 1 and n a positive number. Calling random_negative_binomial with a third argument m, a random sample of size m will be simulated.

Algorithm described in Devroye, L. (1986) Non-Uniform Random Variate Generation. Springer Verlag, p. 480.

To make use of this function, write first load("distrib").


Previous: Hypergeometric Random Variable, Up: Functions and Variables for discrete distributions   [Contents][Index]