Skip to main content
GameDev.net gamedev.net
🔒 Locked

A real mind bender

Started by Xtremehobo Feb 4, 2004 at 7:02 PM 162 replies 19.5k views
Original Post
Xtremehobo
Xtremehobo
On our biology final test, we were asked the final question for extra credit: There are three pancakes in a hat. One pancake is golden on both sides, one is brown on both sides, and the last is gold on one side and brown on the other. You draw one pancake from the hat and the side you see is brown. What's the probability the other side of the pancake you drew is brown? Most people in my class (including me) figgured it was 1/2 but the teacher told is it was 2/3. I decided to write a program testing this by randomly setting up the pancake sides and checking the other side of the "drawn" one. However, It's showing the probibility as being ~50% (determined by dividing the number of pancakes with brown on the other side by the total number of pancakes checked.) Here's some of the results it's been giving me (p1s1 stands for pancake 1 side 1 and p1s1 will always be 2 representing the brown side I drew. Program checks pancake 1 side 2 to see what color it is). 1 = gold, 2 = brown

p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 2Total Golds: 1
Probability: 2
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 3Total Golds: 1
Probability: 1.5
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 3Total Golds: 2
Probability: 1
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 4Total Golds: 2
Probability: 1
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 4Total Golds: 3
Probability: 0.8
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 4Total Golds: 4
Probability: 0.666667
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 5Total Golds: 4
Probability: 0.714286
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 6Total Golds: 4
Probability: 0.75
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 6Total Golds: 5
Probability: 0.666667
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 7Total Golds: 5
Probability: 0.7
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 7Total Golds: 6
Probability: 0.636364
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 7Total Golds: 7
Probability: 0.583333
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 8Total Golds: 7
Probability: 0.615385
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 9Total Golds: 7
Probability: 0.642857
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 9Total Golds: 8
Probability: 0.6
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 10Total Golds: 8
Probability: 0.625
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 10Total Golds: 9
Probability: 0.588235
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 10Total Golds: 10
Probability: 0.555556
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 11Total Golds: 10
Probability: 0.578947
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 12Total Golds: 10
Probability: 0.6
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 12Total Golds: 11
Probability: 0.571429
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 13Total Golds: 11
Probability: 0.590909
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 13Total Golds: 12
Probability: 0.565217
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 13Total Golds: 13
Probability: 0.541667
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 14Total Golds: 13
Probability: 0.56
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 15Total Golds: 13
Probability: 0.576923
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 15Total Golds: 14
Probability: 0.555556
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 16Total Golds: 14
Probability: 0.571429
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 16Total Golds: 15
Probability: 0.551724
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 16Total Golds: 16
Probability: 0.533333
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 17Total Golds: 16
Probability: 0.548387
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 18Total Golds: 16
Probability: 0.5625
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 18Total Golds: 17
Probability: 0.545455
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 19Total Golds: 17
Probability: 0.558824
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 19Total Golds: 18
Probability: 0.542857
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 19Total Golds: 19
Probability: 0.527778
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 20Total Golds: 19
Probability: 0.540541
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 21Total Golds: 19
Probability: 0.552632
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 21Total Golds: 20
Probability: 0.538462
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 22Total Golds: 20
Probability: 0.55
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 22Total Golds: 21
Probability: 0.536585
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 22Total Golds: 22
Probability: 0.52381
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 23Total Golds: 22
Probability: 0.534884
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 24Total Golds: 22
Probability: 0.545455
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 24Total Golds: 23
Probability: 0.533333
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 25Total Golds: 23
Probability: 0.543478
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 25Total Golds: 24
Probability: 0.531915
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 25Total Golds: 25
Probability: 0.520833
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 26Total Golds: 25
Probability: 0.530612
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 27Total Golds: 25
Probability: 0.54
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 27Total Golds: 26
Probability: 0.529412
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 28Total Golds: 26
Probability: 0.538462
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 28Total Golds: 27
Probability: 0.528302
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 28Total Golds: 28
Probability: 0.518519
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 29Total Golds: 28
Probability: 0.527273
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 30Total Golds: 28
Probability: 0.535714
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 30Total Golds: 29
Probability: 0.526316
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 31Total Golds: 29
Probability: 0.534483
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 31Total Golds: 30
Probability: 0.525424
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 31Total Golds: 31
Probability: 0.516667
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 32Total Golds: 31
Probability: 0.52459
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 33Total Golds: 31
Probability: 0.532258
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 33Total Golds: 32
Probability: 0.52381
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 34Total Golds: 32
Probability: 0.53125
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 34Total Golds: 33
Probability: 0.523077
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 34Total Golds: 34
Probability: 0.515152
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 35Total Golds: 34
Probability: 0.522388
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 36Total Golds: 34
Probability: 0.529412
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 36Total Golds: 35
Probability: 0.521739
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 37Total Golds: 35
Probability: 0.528571
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 37Total Golds: 36
Probability: 0.521127
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 37Total Golds: 37
Probability: 0.513889
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 38Total Golds: 37
Probability: 0.520548
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 39Total Golds: 37
Probability: 0.527027
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 39Total Golds: 38
Probability: 0.52
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 40Total Golds: 38
Probability: 0.526316
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 40Total Golds: 39
Probability: 0.519481
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 40Total Golds: 40
Probability: 0.512821
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 41Total Golds: 40
Probability: 0.518987
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 42Total Golds: 40
Probability: 0.525
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 42Total Golds: 41
Probability: 0.518519
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 43Total Golds: 41
Probability: 0.52439
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 43Total Golds: 42
Probability: 0.518072
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 43Total Golds: 43
Probability: 0.511905
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 44Total Golds: 43
Probability: 0.517647
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 45Total Golds: 43
Probability: 0.523256
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 2 p3s1: 1 p3s2: 1
Total Browns: 45Total Golds: 44
Probability: 0.517241
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 2 p3s1: 2 p3s2: 1
Total Browns: 46Total Golds: 44
Probability: 0.522727
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 2 p2s2: 1 p3s1: 2 p3s2: 2
Total Browns: 46Total Golds: 45
Probability: 0.516854
-------------------------------------------------------
p1s1: 2 p1s2: ->1<- p2s1: 1 p2s2: 2 p3s1: 1 p3s2: 2
Total Browns: 46Total Golds: 46
Probability: 0.511111
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 1 p2s2: 1 p3s1: 2 p3s2: 1
Total Browns: 47Total Golds: 46
Probability: 0.516484
-------------------------------------------------------
p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2
Total Browns: 48Total Golds: 46
Probability: 0.521739
-------------------------------------------
Am I just doing something wrong here or is my progrm showing something otherwise? At first, it's showing some results that look closer to 2/3 but later on it levels out at around .51 or so... Here's the source if anybody's interested [edited by - Xtremehobo on February 4, 2004 8:06:57 PM]
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them
Palidine
Palidine
ah

the trick here is that you are picking sides of a pancake, not a whole pancake. so if you''ve picked a brown side, there are 3 respective sides that can be on the other side, one gold and 2 browns. so there is 2/3 a chance for brown being on the other side....

make sense?

-me
Haytil
Haytil
It''s 1/2. Your teacher is wrong.
Haytil
Haytil
The fact that you are picknig side''s, and not whole pancakes, is irrelevant. It''s pretty apparent to me that a pancake would have to have two sides. You are looking at the other side of the pancake you drew.
alexmoura
alexmoura
Palidine''s got it - you''re probably counting whole gold pancakes that you got out of the hat.
Since you already know that the pancake you have has at least one brown side, you know you are holding one of only three possible pancakes - and in that set, two will have the other side brown, one will have it golden, hence, a 2/3 probability of the other side also being brown.
Xtremehobo
Xtremehobo
Now I''m getting a bit confused :\

The count of gold pancakes taken out of the hat shouldn''t be realivent to the predicted probability.


However, I''m beginning to think there''s something wrong with my random number generator. If you search the string "p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2" in the results, you''ll see it comes up every three result-sample-thinggies. Maybe I should only seed the random number generator once in the program?
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them
Prozak
Prozak
The way a problem is structured is very determining of how it should be solved.

The correct answer is of course 1/2, no matter what everyone tells you.

You teacher is just trying to make herself look smarter by pulling some basic Math trick.

When you get the test back can you post the *exact* phrasing of the question? That is very important. If it was as you said in your original post, then I stand by my answer.

The result 2/3 falls outside of the Universe of the result:
"What is the probability that the OTHER side is also brown".

That sentence defines our Universe as:
U = {Brown-Brown; Brown-Gold}

The Gold-Gold pancake doesnt even make it into the problem, because it fails to pass the universe analisis test, a basic step in probability solving your math teacher should know about.

Jester Says: Visit Positronic Dreams!
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
"I say we take off and nuke the entire site from orbit. It''s the only way to be sure."
reana1
reana1
quote:
Original post by Palidine
the trick here is that you are picking sides of a pancake, not a whole pancake. so if you''ve picked a brown side, there are 3 respective sides that can be on the other side, one gold and 2 browns. so there is 2/3 a chance for brown being on the other side....

make sense?

That doesn''t make sense to me. If you''ve picked a pancake with a brown side up, then there are only 2 possibilities that fit (brown on both sides or brown on only the side you see). The 3rd is impossible since it can''t be gold on both sides and have a brown side up at the same time.

quote:
Original post by alexmoura
Palidine''s got it - you''re probably counting whole gold pancakes that you got out of the hat.
Since you already know that the pancake you have has at least one brown side, you know you are holding one of only three possible pancakes - and in that set, two will have the other side brown, one will have it golden, hence, a 2/3 probability of the other side also being brown.


If you already no one side is brown, how can two in that set have the other side brown? That would mean there are two pancakes that are brown on both sides.

I think 50% sounds right. Given that you are holding a pancake with one side brown, what are the odds that the other side is brown too? There are only 2 pancakes that you can hold that have brown on one side. And of those only 1 is brown on both sides so 1/2.

Tadd
- WarbleWare
Tadd- WarbleWare
pinacolada
pinacolada
quote:
Original post by Xtremehobo
However, I''m beginning to think there''s something wrong with my random number generator. If you search the string "p1s1: 2 p1s2: ->2<- p2s1: 2 p2s2: 1 p3s1: 1 p3s2: 2" in the results, you''ll see it comes up every three result-sample-thinggies. Maybe I should only seed the random number generator once in the program?


that''s correct, you should only seed the random numbers once in the program
ajas95
ajas95
If you call the pancakes bb, bg, and gg, the theory behind 50/50 odds is that bb and bg will be chosen with equal probability, so half the time the opposite side is brown, and half the time its golden... The problem with this reasoning is that half the time you choose bg, the side you see is gold so you don''t even bother checking the other side (it doesn''t count toward your result). But EVERY time you select bb, it counts toward your results. So bb constitutes twice as many entries in your result set as bg, so the answer is 2/3.
Prozak
Prozak
Here is another test that seems similar to that one, another probability mind-bender

I think your teacher was trying to pull a similar trick without understanding the underlying factors...

Jester Says: Visit Positronic Dreams!
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
"I say we take off and nuke the entire site from orbit. It''s the only way to be sure."
alexmoura
alexmoura
ignore me - for some reason I read 5 pancakes, with one having the gold/brown sides.

With three pancackes, yep, it should be 0.5
Xtremehobo
Xtremehobo
er wait... It has to be 2/3.

Think about it like this:

You draw one pancake, the side is brown. Just throw the gold-gold pancake out because it's impossible that you have it.

That means you're holding one of two pancakes. Of those two pancakes, there's 3 more sides you don't know. One is gold and the other two are brown.

What does that mean? That means that the other side can be one of three different sides. Two of them are brown, and one is gold.

Then the probability that it'll be brown is 2(browns) out of 3(total), or 2/3

hmms

EDIT2: wait no....
Something doesnt seem right with that although I cant put it into words :


[edited by - Xtremehobo on February 4, 2004 8:49:21 PM]
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them
reana1
reana1
Ok I change my answer. Though I still haven't understood anyone's explanation yet. But mathematically the answer is 2/3.

This is a conditional probabilty. Given that you have chosen a pancake with brown side up, what are the odds that you have a pancake that's brown on both sides?
P(A) = P(brown on both sides) = 1/3 (only 1 of 3 pancakes matches)
P(B) = P(brown up) = 3/6 (the chance of drawing one brown side up)

So conditional probability is P(A|B) = P(A intersect B) / P(B). (yes I had to look it up )
In this case P(A intersect B) is P(A) since the intersection of the A and B sets is still just A.
P(A|B) = (1/3) / (3/6) = 2/3.

Rerun with the seeding fixed and see if you get 2/3 now.
Hope I did that right.

Edit: Here's conditional probabilities
Tadd
- WarbleWare

[edited by - reana1 on February 4, 2004 9:07:25 PM]

[edited by - reana1 on February 4, 2004 9:08:22 PM]
Tadd- WarbleWare
Xtremehobo
Xtremehobo
ok, I seeded it only once and it''s still giving me 50%...

hmm...
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them
SpaceDude
SpaceDude
quote:
Original post by ajas95
If you call the pancakes bb, bg, and gg, the theory behind 50/50 odds is that bb and bg will be chosen with equal probability, so half the time the opposite side is brown, and half the time its golden... The problem with this reasoning is that half the time you choose bg, the side you see is gold so you don't even bother checking the other side (it doesn't count toward your result). But EVERY time you select bb, it counts toward your results. So bb constitutes twice as many entries in your result set as bg, so the answer is 2/3.


Yeh you're right... I was gonna post that the probability was 50/50, but now i see the reasoning behind the 2/3

I think the question is badly worded, and either solution is correct depending on how you interpret it.

if it was changed from:

"There are three pancakes in a hat. One pancake is golden on both sides, one is brown on both sides, and the last is gold on one side and brown on the other. You draw one pancake from the hat and the side you see is brown. What's the probability the other side of the pancake you drew is brown?"

to

"There are three pancakes in a hat. One pancake is golden on both sides, one is brown on both sides, and the last is gold on one side and brown on the other. You draw pancakes from the hat until the side you see is brown, golden pancakes are randomly placed back in the hat. What's the probability the other side of the pancake you drew is brown?"

then the solution would definetly have to be 2/3

[edited by - SpaceDude on February 4, 2004 9:09:41 PM]
reana1
reana1
quote:
Original post by Xtremehobo
ok, I seeded it only once and it''s still giving me 50%...

hmm...

I think the problem with the code is you are forcing the p1s1 to be brown. But that''s not the same problem. Your code would be answering the problem "If you are only able to draw pancakes out with brown side up (which your code enforces), what''s the chance that the other side is brown?" This is 50% since then the gold-gold doesn''t even matter. This is why wording of the question is important (as pentium3id said). The question should be careful to explicitly say that you *can* draw gold up, but given that you''ve drawn brown up what''s the chances of brown-brown. But it''s hard to put this in words. I can''t think of way to explain it clearly other than mathematically.

To code it up, you''d have to run without forcing the p1s1 to be brown. But then the probabilty isn''t just computed as number of (p1s2''s that are brown)/total. You''d have to use the conditional probaility calculation, since that''s what this is.

Tadd
- WarbleWare
Tadd- WarbleWare
Xtremehobo
Xtremehobo
ok, I think I can prove that it's 1/2.


Because it cannot be the gold-gold pancake, that means the pancake we drew can only be one of two pancakes, the brown-brown or the gold-brown.

If it was the brown-brown, the other side must be brown
If it was the gold-brown, the other side must be gold

Therefore, the other side will either be the gold side of the brown-gold, or the other brown side of the brown-brown. 50% 1/2.


@SpaceDude: Yes, if the question was re-worded like that, it would be 2/3, however, those questions are asking two completely different things and I think the original question was worded as it was ment to be.


[edited by - Xtremehobo on February 4, 2004 9:41:11 PM]
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them
cowsarenotevil
cowsarenotevil
Foo''s.

The Gold-Brown pancake may get picked up gold side UP, so the most likely one to be brown when you grab it is the Brown-Brown. Thus, 2/3.

Or something.

-~-The Cow of Darkness-~-
ajas95
ajas95
try the following (I haven''t run it, so you might get a trivial compiler error...)

enum { BROWN = 0, GOLD };

struct Pancake
{
int side[2];
Pancake(int side0, int side1) { side[0] = side0; side[1] = side1; }
};

int main(void)
{
Pancake bb(BROWN, BROWN);
Pancake bg(BROWN, GOLD);
Pancake gg(GOLD, GOLD);

Pancake *cakes[3] = {&bb, &bg, ≫};
int side_total[2] = {0, 0};
int num_iterations = 10000;
float total_results = 0.0f;

for(int i = 0; i < num_iterations; i++)
{
// pick a pancake;
Pancake *cake = cakes[rand() % 3];

// pick a side;
int iSide = rand() % 2;
if(cake->side[iSide] != BROWN)
continue;

side_total[cake->side[!iSide]]++;
total_results ++;
}

cout << "Total Brown: " << side_total[BROWN] / total_results << endl;
cout << "Total Gold: " << side_total[GOLD] / total_results << endl;
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.