Random Number Generation Question

In summary, the conversation discusses the use of the rejection method to generate a random number based on a given probability table. The method involves selecting a random number and comparing it to the probability of a corresponding value of X. If the probability is greater than the random number, the value of X is accepted. The conversation also addresses a question about accommodating for values of X that are less than 1 and suggests adding 1 to the calculated number to get the desired results.
  • #1
Pyroadept
89
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
  • #2
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.
 
  • #3
Thanks :)
 

Related to Random Number Generation Question

What is random number generation?

Random number generation is the process of generating a sequence of numbers or symbols that cannot be reasonably predicted better than by a random chance, usually through a computer program.

Why is random number generation important in science?

Random number generation is essential in science because it allows for controlled experiments and unbiased data collection. By using random numbers, scientists can ensure that their results are not influenced by any outside factors and are truly representative of the population being studied.

What are some methods of random number generation?

Some methods of random number generation include using physical devices such as dice, coins, or cards, or using computational algorithms that produce numbers based on a seed value.

What is the role of random number generation in statistics?

In statistics, random number generation is used to select a random sample from a larger population. This allows for statistical analysis and hypothesis testing to be performed on the sample and then generalized to the larger population.

How can we ensure the randomness of generated numbers?

To ensure the randomness of generated numbers, it is important to use a reliable and tested random number generator. Additionally, the generator should have a large enough seed value and be periodically checked for any patterns or biases in the generated numbers.

Similar threads

  • Calculus and Beyond Homework Help
Replies
9
Views
2K
  • Programming and Computer Science
Replies
1
Views
782
  • Set Theory, Logic, Probability, Statistics
Replies
15
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
Replies
5
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
22
Views
4K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
Back
Top