Pre-Engineering 220 Introduction to MatLab ® & Scientific Programming j kiefer



Download 8.69 Mb.
Page97/128
Date02.05.2018
Size8.69 Mb.
#47255
1   ...   93   94   95   96   97   98   99   100   ...   128

2. Samples of Random Sampling

a. Coin toss

We have two outcomes for each toss, of equal probability. We’ll generate an integer, either 1 or 2, using a pseudorandom number generator.
zi = a uniformly distributed pseudorandom number in (0,1)

j = int(2*zi) + 1 = 1 or 2
We’ll say that if j = 1, it’s heads, if j = 2 it’s tails.
b. Roll of a die

In this case we have six outcomes, of equal probability (we hope). So we need to produce an integer from 1 to 6.


j = int(6*zi)+1 = 1, 2, 3, 4, 5 or 6
Now, if it is known that the die is loaded, we use a different scheme, creating subintervals in (0,1) whose lengths reflect the relative probabilities of the faces of the die coming up. For instance, we might say that


zi

j



1



2


Download 8.69 Mb.

Share with your friends:
1   ...   93   94   95   96   97   98   99   100   ...   128




The database is protected by copyright ©ininet.org 2024
send message

    Main page