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

  • Context: Undergrad 
  • Thread starter Thread starter gsingh2011
  • Start date Start date
  • Tags Tags
    Random Random number
Click For Summary

Discussion Overview

The discussion revolves around generating a random number from 0 to 6 based on an initial random input of 0, 1, 2, or 3, ensuring that each output number has an equal probability. Participants explore the mathematical implications and potential methods for achieving this uniform distribution.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • Some participants emphasize the need to define how the first random number influences the second output, suggesting that without this, the outcomes remain independent.
  • One participant proposes using mathematical operations, such as floor and ceiling functions, to transform the initial number into a new range while maintaining uniform probability across the outputs.
  • Another participant questions the distinction between random and uniform outputs, suggesting that uniformity does not necessarily imply randomness.
  • A suggestion is made to generate two random integers from 0 to 3 and use them to derive a number from 0 to 6, although the effectiveness of this method is uncertain.
  • One participant introduces a method of generating numbers in base 4 to express values from 0 to 15, noting that this approach could lead to equal probabilities for the desired outputs, though it may not always terminate.
  • Another participant speculates that using functions could yield fewer unique outcomes than intended, potentially limiting the range of results.

Areas of Agreement / Disagreement

Participants express various methods and ideas, but there is no consensus on a single approach or solution. Multiple competing views and uncertainties remain regarding the best way to achieve the desired uniform distribution.

Contextual Notes

Participants mention the potential for non-integer outcomes and the implications of using different mathematical functions, but these aspects remain unresolved and depend on specific definitions and assumptions.

gsingh2011
Messages
115
Reaction score
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
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:
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?
 
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:
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.
 
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.
 

Similar threads

  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 41 ·
2
Replies
41
Views
5K