Math with random numbers

Discussion in 'Off-Topic' started by Souron, Aug 20, 2005.

1. SouronThe Dark Lord

Joined:
Mar 9, 2003
Messages:
5,947
Location:
(GMT-5)
In Excel Code:
is this:
=ROUNDUP(RAND()*6,0)
Equal to this:
=ROUNDUP(RAND()*3,0)+IF(ROUNDUP(RAND()*2,0)>1,3,0)

In words:
If you take a random integer out of the set {1,2,3} and add a random integer out of the set {0,3}, will there be an equal probability of getting each possible result?

Yes or no, and how do you know?

If anybody wishes to reword my question into some other form or phrasing so that others may understand it better, that would be helpful.

2. DBearunbeliever

Joined:
Dec 27, 2003
Messages:
3,262
Location:
Prime Material
No. Random (6..0) will have each number come up with equal chance. 1/6 for 1, 1/6 for 2, etc.
Your second option. (1,3) + (0,3) will get a result similar to rolling dice. There are 12 possibilities. 1/12 for 1, 2/12 for 2 (1,1) or (2,0) , 3/12 for 3, 3/12 for 4, 2/12 for 5, 1/12 for 6. Instead of a linear distribution as in the first example, you have a binomial distribution.

 errr...nevermind. Misunderstood the question

3. SouronThe Dark Lord

Joined:
Mar 9, 2003
Messages:
5,947
Location:
(GMT-5)
(1,1) is not a valid possiblility. The second value(the value added) must be either 0 or 3.

4. Miseisle of lucy

Joined:
Apr 13, 2004
Messages:
28,622
Location:
London, UK
Yes, it should be the same. Not sure how to explain why though...

EDIT: ok i'll have a go...

Basically you're asking two separate questions:
1) pick a random number between 1 and 3
OR
2) pick a random number between 4 and 6

the probability of (1) or (2) happening is equal, and the probability within (1) and (2) is equal for all outcomes, therefore the probability of getting the number is the same for each number.

(it's far too late for me to be explaining this sort of thing sorry if it makes no sense)

5. SouronThe Dark Lord

Joined:
Mar 9, 2003
Messages:
5,947
Location:
(GMT-5)
I get it, thank you.

6. SouronThe Dark Lord

Joined:
Mar 9, 2003
Messages:
5,947
Location:
(GMT-5)
Wait, So there is no way to prove that without testing each possible value combination?

7. SonicXEmperor

Joined:
Aug 11, 2005
Messages:
1,267
Location:
Republic of Flanders (Be)
A : ROUNDUP(RAND()*6,0) gives : {1,2,3,4,5,6} with a 1/6 chance of each.
B : ROUNDUP(RAND()*3,0) gives : {1,2,3} with a 1/3 chance of each.
C :IF(ROUNDUP(RAND()*2,0)>1,3,0) : gives {0,3} with a 1/2 chance of each.
B+C gives {1,2,3} + {0,3} with even chances, so {1,2,3,4,5,6} with a 1/6 chance for each.

Seems normal ?

8. GyathaarWarlockRetired ModeratorGOTM Staff

Joined:
Nov 19, 2003
Messages:
3,753
Location:
Trondheim, Norway
depends.. I am not familiar with excel functions.. does RAND() return a number x so that:
a) 0 < x <= 1
or
b) 0 <= x < 1

if case b, then there is a slightly bigger chance of getting 0 than 3 in the 2nd part on the last function

9. SonicXEmperor

Joined:
Aug 11, 2005
Messages:
1,267
Location:
Republic of Flanders (Be)
That is irrelevant is the numbers after the comma are high.

10. GyathaarWarlockRetired ModeratorGOTM Staff

Joined:
Nov 19, 2003
Messages:
3,753
Location:
Trondheim, Norway
Oops.. I missed the roundup.. that actually gives that case a gives higher chance for 3 than 0..
why? because if rand() can be 1, then roundup(rand()*2.0) then be 1, 2 or 3

11. SonicXEmperor

Joined:
Aug 11, 2005
Messages:
1,267
Location:
Republic of Flanders (Be)
No, ]0,1] will give 1 and ]1,2] will give 2. Only the 0,000 causes a slight imbalance, but that's because the total possible numbers is always a tenfold +1 (11, 101, 1001 and so on, depending on the numbers of decimals)

12. Miseisle of lucy

Joined:
Apr 13, 2004
Messages:
28,622
Location:
London, UK
Well I don't know if there's a formal proof, but what I said was a proof of sorts that didn't require any testing. The numbers could have been A to B and B+1 to B+B and it would give the same probability distribution as doing A to B+B.

13. YanivPrince

Joined:
Jun 15, 2002
Messages:
528
Location:
Alone, in my room
The two are the same. Probibility is my favorite subject so I have no trouble with this problem.

In order to get the value 1, you need to get 1 from the first set (probiblity of 1/3) and 0 in the second set (probiblity of 1/2) : 1/3*1/2 = 1/6

In order to get the value 2, you need to get 1 from the first set (probiblity of 1/3) and 0 in the second set (probiblity of 1/2) : 1/3*1/2 = 1/6
.
.
.
In order to get the value 6, you need to get 3 from the first set (probiblity of 1/3) and 3 in the second set (probiblity of 1/2) : 1/3*1/2 = 1/6

In other words, each of the six numbers has 1/6 option of being picked.
And all together the probability adds up to 1, exactly like it should.