Page 40 - Computational Statistics Handbook with MATLAB
P. 40
26 Computational Statistics Handbook with MATLAB
Example 2.1
Suppose there is a 20% chance that an adult American suffers from a psychi-
atric disorder. We randomly sample 25 adult Americans. If we let X represent
the number of people who have a psychiatric disorder, then X is a binomial
random variable with parameters 25 0.20,( ) . We are interested in the proba-
bility that at most 3 of the selected people have such a disorder. We can use
the MATLAB Statistics Toolbox function binocdf to determine PX ≤( 3) , as
follows:
prob = binocdf(3,25,0.2);
We could also sum up the individual values of the probability mass function
from X = 0 to X = : 3
prob2 = sum(binopdf(0:3,25,0.2));
Both of these commands return a probability of 0.234. We now show how to
generate the binomial distributions shown in Figure 2.3.
% Get the values for the domain, x.
x = 0:6;
% Get the values of the probability mass function.
% First for n = 6, p = 0.3:
pdf1 = binopdf(x,6,0.3);
% Now for n = 6, p = 0.7:
pdf2 = binopdf(x,6,0.7);
Now we have the values for the probability mass function (or the heights of
the bars). The plots are obtained using the following code.
% Do the plots.
subplot(1,2,1),bar(x,pdf1,1,'w')
title(' n = 6, p = 0.3')
xlabel('X'),ylabel('f(X)')
axis square
subplot(1,2,2),bar(x,pdf2,1,'w')
title(' n = 6, p = 0.7')
xlabel('X'),ylabel('f(X)')
axis square
Poi
n
PPooii
sssoso
Po isssoson nn
λλ
A random variable X is a Poisson random variable with parameter , > , 0
if it follows the probability mass function given by
λ λ x
(
–
,,
(
f x λ) = PX = x) = e -----; x = 0 1 … (2.25)
;
x!
© 2002 by Chapman & Hall/CRC