Matvec Users’ Guide
Matvec Users' Guide
Matvec Users' Guide
- No tags were found...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
13.3. DISCRETE DISTRIBUTION 105<br />
<strong>Matvec</strong> interface<br />
An object of P (λ) can be created by<br />
D = StatDist("Poisson",lambda);<br />
<strong>Matvec</strong> provided several standard member functions to allow user to access most of properties and<br />
functions of P (λ):<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 λ.<br />
mean D.mean() returns the expected value.<br />
variance D.variance() returns the variance.<br />
Examples<br />
> D = StatDist("Poisson",10)<br />
PoissonDist(10)<br />
> D.sample(1000).mean()<br />
10.199<br />
> D.sample(1000).variance()<br />
9.98214<br />
> D.pdf([0,10,100])<br />
Col 1 Col 2 Col 3<br />
Row 1 4.53999e-05 0.125110 4.86465e-63<br />
> D.cdf([0,10,100])<br />
Col 1 Col 2 Col 3<br />
Row 1 4.53999e-05 0.583040 1.00000<br />
> D.inv(0.5)<br />
***ERROR***<br />
PoissonDist::inv(): not available<br />
13.3.3 Geometric distribution<br />
Definition<br />
The random variable X has a geometric distribution if its probability density function (pdf) is defined by<br />
f(x) = (1 − p) x p, x = 0, 1, 2, . . . , (13.16)<br />
where p (real) is the parameter with its range 0 ≤ p ≤ 1. In short, we say X ∼ g(p).<br />
For example, let X be the number of failures before the first success in a sequence of Bernoulli trials with<br />
probability of success p, then X ∼ g(p).