Given a random number from 0-3, return a random number from 0-6

In summary: For example, suppose the program outputs 5 as the result of performing floor(f(x)). We would then have two outcomes, which means that the probability of each of those outcomes is 1/4.
  • #1
gsingh2011
115
1
This is actually for a program, but the challenging part is really the math. So you're given a number 0, 1, 2, or 3 and the probability of getting each is the same. Now given this random number, I need to output a number 0, 1, 2, 3, 4, 5, or 6 but the probability of getting each number needs to be the same.

Can anyone point me in the right direction?
 
Physics news on Phys.org
  • #2
gsingh2011 said:
This is actually for a program, but the challenging part is really the math. So you're given a number 0, 1, 2, or 3 and the probability of getting each is the same. Now given this random number, I need to output a number 0, 1, 2, 3, 4, 5, or 6 but the probability of getting each number needs to be the same.

Can anyone point me in the right direction?

You need to specify how the outcome of the first round will affect the second round. Otherwise you just have two independent outcomes a,b. Then the probability of any pair is 1/28.
 
Last edited:
  • #3
SW VandeCarr said:
You need to specify how the outcome of the first round will affect the second round. Otherwise you just have two independent outcomes a,b. Then the probability of any pair is 1/28.

Well the relationship is that after being given this random number from 0-3, you need to perform mathematical operations (functions such as floor and ceiling are allowed) to arrive at a new number from 0-6. Now if you performed these same steps for the random input number many times, you would end up with the numbers from 0-6 an approximately equal number of times (probability of getting each number is the same). Does that clarify the problem?
 
  • #4
MisterX said:
These functions are for use with non-integer numbers.
I thought division might be involved, resulting in non-integers.

However, if the output needn't be random, but only uniform
What's the difference? I thought if something was random, the probability for each result would be the same (uniform).

You could do something like generate a second 0-3 integer pseudorandomly and determine the 0-6 integer using the two integers. You could have the program do something somewhat similar if you are able to get two 0-3 random integers.
I'll try it out, see if I can come up with anything.

If anyone else has any other ideas, please share them.

EDIT: Seems like the person above me deleted their post, making me seem crazy.
 
Last edited:
  • #5
You can randomize 0,1,2,3 twice to randomly express any number from 0 through 15 in base 4. Keep doing that till you get a number in the desired range. This procedure is not guaranteed to terminate, but each of 0 through 6 have the same probability of being chosen. Just a thought.
 
  • #6
gsingh2011 said:
I thought division might be involved, resulting in non-integers.
.

Suppose x is a random integer from 0-3.

Suppose the program performs something such as floor(f(x)). Where f is a function by the mathematical definition of a function.

We may get from this, a maximum of four unique outcomes, which is what we started with (four values of x). But we may actually end up with less.
 

FAQ: Given a random number from 0-3, return a random number from 0-6

1. How does the random number generator work in this scenario?

The random number generator used in this scenario follows a uniform distribution, meaning each number from 0 to 3 has an equal chance of being selected. This ensures that the returned number will truly be random.

2. Is there a way to control the range of numbers returned?

Yes, the range of numbers returned can be controlled by adjusting the parameters of the random number generator. For example, if you wanted to return a random number from 0-10, you would simply change the upper limit from 6 to 10.

3. Can this method return decimal numbers?

No, this particular method only returns whole numbers. If you need to return decimal numbers, you can use a different random number generator that allows for decimal values.

4. How accurate and reliable is this method in returning truly random numbers?

This method uses a well-tested and established random number generator, so the numbers returned can be considered truly random. However, it is important to note that in any random process, there is always a small chance of patterns or biases emerging.

5. Can this method be used for any range of numbers?

Yes, this method can be used for any range of numbers as long as the parameters of the random number generator are adjusted accordingly. It can also be applied to non-numeric ranges, such as returning a random letter from the alphabet.

Similar threads

Back
Top