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


by gsingh2011
Tags: number, random, return
gsingh2011
gsingh2011 is offline
#1
Sep18-11, 01:38 PM
P: 113
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?
Phys.Org News Partner Science news on Phys.org
Going nuts? Turkey looks to pistachios to heat new eco-city
Space-tested fluid flow concept advances infectious disease diagnoses
SpaceX launches supplies to space station (Update)
SW VandeCarr
SW VandeCarr is offline
#2
Sep18-11, 02:41 PM
P: 2,490
Quote Quote by gsingh2011 View Post
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.
gsingh2011
gsingh2011 is offline
#3
Sep18-11, 03:38 PM
P: 113
Quote Quote by SW VandeCarr View Post
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?

gsingh2011
gsingh2011 is offline
#4
Sep18-11, 07:38 PM
P: 113

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


Quote Quote by MisterX View Post
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 similiar 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.
SteveL27
SteveL27 is offline
#5
Sep18-11, 08:07 PM
P: 799
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.
MisterX
MisterX is offline
#6
Sep18-11, 08:14 PM
P: 536
Quote Quote by gsingh2011 View Post
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.


Register to reply

Related Discussions
MATLAB - random allocation of random number Engineering, Comp Sci, & Technology Homework 1
Sum of random number of random variables Set Theory, Logic, Probability, Statistics 8
Expectation and variance of a random number of random variables Calculus & Beyond Homework 3
Random Number Precalculus Mathematics Homework 2
Random Number Set Theory, Logic, Probability, Statistics 0