Here is the question I'm working on:
Consider the following probability table:
X 1 2 3 4
P(X) 0.4 0.25 0.25 0.1
Use the rejection method to generate a random number.
Use the following list of random numbers:
0.6072, 0.4893, 0.0899, 0.3456, 0.4419, 0.4694, 0.3134, 0.6266, 0.4424
If you run out of numbers, start again.
So I know how to do this (let X_C = INT(4*R_1), where R_1 is one of the random numbers, and then accept if P(X_C) > R_2, where R_2 is the next random number in the sequence.
My question is this though - in all the examples I can find of this kind of method, one of the values of X is always 0 to accommodate for X_C's that are less than 1. Also, under this method as above, it would be impossible to ever generate 4. So should I shift all the numbers down one? As in make 1=0, 2=1, 3=2 and 4=3, for the purposes of calculating the random numbers?
Thanks for any help!