Random Number Generation Question

Click For Summary
The discussion revolves around using the rejection method for random number generation based on a given probability table. The user seeks clarification on whether to adjust the values of X by shifting them down to accommodate the method, as the current approach does not allow for generating the maximum value of 4. It is suggested that instead of shifting, the user can simply add 1 to the generated numbers to align with the desired outcomes of 1, 2, 3, and 4. The conversation emphasizes the importance of correctly implementing the rejection method to ensure all values can be generated. Proper adjustments are crucial for accurate random number generation.
Pyroadept
Messages
82
Reaction score
0

Homework Statement




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.




Homework Equations





The Attempt at a Solution



Hi everyone,

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!
 
Physics news on Phys.org
Yes, the numbers you want to get are 1, 2, 3, 4 and your method gives, instead, 0, 1, 2, 3. Just add 1 to whatever number you get.
 
Thanks :)
 
Question: A clock's minute hand has length 4 and its hour hand has length 3. What is the distance between the tips at the moment when it is increasing most rapidly?(Putnam Exam Question) Answer: Making assumption that both the hands moves at constant angular velocities, the answer is ## \sqrt{7} .## But don't you think this assumption is somewhat doubtful and wrong?

Similar threads

Replies
9
Views
4K
Replies
8
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 15 ·
Replies
15
Views
2K
Replies
3
Views
1K
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
890
Replies
2
Views
1K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 22 ·
Replies
22
Views
2K