next up previous contents
Next: RANDF Generate F-Distributed Random Up: Random Number Generation Previous: RANDBIN Generate Binomial Random   Contents

Subsections

RANDNBIN Generate Negative Binomial Random Variables

Usage

Generates random variables with a negative binomial distribution. The general syntax for its use is

   y = randnbin(r,p)

where r is a vector of integers representing the number of successes, and p is the probability of success.

Function Internals

A negative binomial random variable describes the number of failures x that occur in x+r bernoulli trials, with a success on the x+r trial. The pdf is given by

$\displaystyle P_{r,p}(x)=\left(\begin{matrix}x+r-1 r-1\end{matrix}\right)p^r(1-p)^x.
$

Example

Here we generate some negative binomial random variables:

--> randnbin(3*ones(1,4),.01)
ans = 
  <uint32>  - size: [1 4]
 
Columns 1 to 4
          419           671           303           422  
--> randnbin(6*ones(1,4),.01)
ans = 
  <uint32>  - size: [1 4]
 
Columns 1 to 4
          320           690           613           433



Samit K. Basu 2005-03-16