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
|
Share with your friends: |