Page 119 - Computational Statistics Handbook with MATLAB
P. 119
106 Computational Statistics Handbook with MATLAB
% Determine the estimated relative frequencies.
relf = zeros(1,N);
for i = 1:N
relf(i) = length(find(x==i))/n;
end
Printing out the observed relative frequencies, we have
relf = 0.1820 0.2080 0.2040 0.1900 0.2160
⁄
which is close to the theoretical value of 1 N⁄ = 15 = 0.2 .
4.5 MATLAB Code
The MATLAB Statistics Toolbox has functions that will generate random
variables from all of the distributions discussed in Section 2.6. As we
explained in that section, the analyst must keep in mind that probability dis-
tributions are often defined differently, so caution should be exercised when
using any software package. Table 4.1 provides a partial list of the MATLAB
functions that are available for random number generation. A complete list
can be found in Appendix E. As before, the reader should note that the
gamrnd, weibrnd, and exprnd functions use the alternative definition for
the given distribution (see 24).
B
L
BL
A
A
4.1
4.1
E
LE
E
T
T
TA
T AB B L E 4.1 4.1
Partial List of Functions in the MATLAB Statistics Toolbox for
Generating Random Variables
Distribution MATLAB Function
Beta betarnd
Binomial binornd
Chi-Square chi2rnd
Discrete Uniform unidrnd
Exponential exprnd
Gamma gamrnd
Normal normrnd
Poisson poissrnd
Continuous Uniform unifrnd
Weibull weibrnd
© 2002 by Chapman & Hall/CRC