tailieunhanh - Computational Statistics Handbook with MATLAB phần 3

Các phương pháp để tạo ra thống nhất riêng biệt được thực hiện trong chức năng, đưa ra dưới đây. Chức năng Chức năng này sẽ tạo ra các biến ngẫu nhiên phân bố đồng đều rời rạc. Nó chọn số thống nhất giữa 1 và N. | X FIGURE This is the histogram for random variables generated from the Poisson with Ấ . X I-NU1 where the function fyl y 0 means to round up the argument y. The next example shows how to implement this in MATLAB. Example The method for generating discrete uniform is implemented in the function csdunrnd given below. function X csdunrnd N n This function will generate random variables from the discrete uniform distribution. It picks numbers uniformly between 1 and N. function X csdunrnd N n X ceil N rand 1 n To verify that we are generating the right random variables we can look at the observed relative frequencies. Each should have relative frequency of 1 N .This is shown below where N 5 and the sample size is 500. N 5 n 500 x csdunrnd N n 2002 by Chapman Hall CRC 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 which is close to the theoretical value of 1 N 1 5 . Matlab Code The MATLAB Statistics Toolbox has functions that will generate random variables from all of the distributions discussed in Section . As we explained in that section the analyst must keep in mind that probability distributions are often defined differently so caution should be exercised when using any software package. Table 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 . TABLE 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 .

TỪ KHÓA LIÊN QUAN