Matvec Users’ Guide
Matvec Users' Guide
Matvec Users' Guide
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
13.3. DISCRETE DISTRIBUTION 107<br />
13.3.4 Negative binomial distribution<br />
Definition<br />
The random variable X has a negative binomial distribution if its probability density function (pdf) is defined<br />
by<br />
f(x) = x + n − 1)!<br />
x!(n − 1)! pn (1 − p) x , x = 0, 1, 2, . . . , (13.17)<br />
where p (real) and n (integer) are the parameters with their ranges 0 ≤ p ≤ 1 and n ≥ 1.<br />
For example, let X be the number of failures before the n’th success in a sequence of Bernoulli trials with<br />
probability of success p, then X is distributed as negative binomial distribution with parameters n and p.<br />
Properties<br />
1. its moment generation function is<br />
M(t) =<br />
2. E(X) = r(1−p)<br />
p<br />
, Var(X) = r(1−p)<br />
p<br />
. 2<br />
<strong>Matvec</strong> interface<br />
p r<br />
[1 − (1 − p)e t , t < −ln(1 − p)<br />
]<br />
r<br />
An object of the negative binomial distribution can be created by<br />
D = StatDist("NegativeBinomial",n,p);<br />
<strong>Matvec</strong> provided several standard member functions to allow user to access most of properties and<br />
functions of the negative binomial distribution:<br />
pdf D.pdf(x) returns the probability density function (pdf) values of x which could be a vector or matrix.<br />
cdf D.cdf(x) returns the cumulative distribution function (cdf) values of x which could be a vector or<br />
matrix<br />
mgf D.mgf(t) returns the moment-generating function (mgf) values of t which could be a vector or matrix.<br />
inv D.inv(p) is the inverse function of D.cdf(x), where p could be a vector or matrix. That is if p =<br />
D.cdf(x), then x = D.inv(p).<br />
sample D.sample(), D.sample(n), and D.sample(m,n) return a random scalar or a vector of size n or a matrix<br />
of size m by n.<br />
parameter D.parameter(1) returns n, number of Bernoulli trials; whereas D.parameter(2) returns p, the probability<br />
of success in a Bernoulli trial.<br />
mean D.mean() returns the expected value.<br />
variance D.variance() returns the variance.<br />
Examples<br />
> D = StatDist("NegativeBinomial",4,0.1)<br />
NegativeBinomialDist(4,0.1)<br />
> D.mean()<br />
36<br />
> D.sample(1000).mean()<br />
36.256<br />
> D.pdf([0,10,100])