Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

  • Index
  •  » Guestbook
  •  » Flaws in logic of solution to a couple of the logic problems

#26 2013-10-26 19:23:43

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: Flaws in logic of solution to a couple of the logic problems

Code:

>>> import random
>>> def pickbag():
    bag = random.randrange(1,4)
    if bag == 1:
        return ['W','B'] #return a bag with a white and a black marble
    elif bag == 2:
        return ['W', 'W']
    else:
        return ['B', 'B']

    
>>> def pickmarble(bag):
    return random.choice(bag) #pick a random marble from the given bag

>>> def seeiftheothermarbleiswhite():
    bag = pickbag()
    marble = pickmarble(bag)
    if marble == 'W':
        if bag == ['W','W']:
            return True # First Marble AND second marble white
        else:
            return False # Only First Marble White
    else:
        return None #First marble is not white, aborting

Now, lets do the experiment 1 00 000 times and Mark the cases as Yes when the other marble are white, No when only the First marble is white, Other when the first is not white.

Code:

>>> Yes = 0
>>> No = 0
>>> Other = 0
>>> for i in xrange(100000):
    a = seeiftheothermarbleiswhite()
    if a:
        Yes += 1
    elif a == False:
        No += 1
    else:
        Other += 1

Now, since we are dealing only with cases when the first marble is white:

Code:

>>> Yes

33351
>>> No

16533
>>> Other

50116

Code:

>>> Yes/float(Yes + No)

0.6685710849170075

Now, that is very close to 2/3 and the rest is experimental error


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Who are you to judge everything?' -Alokananda

#27 2014-01-22 19:44:12

PalmerEldritch
Novice

Offline

Re: Flaws in logic of solution to a couple of the logic problems

ILIA wrote:

Let's say I originally picked door 1 then door 2 was opened showing the goat so we want to calculate probability of car behind door 1 given that door 2 has a goat and probability of car behind door 3 given that door 2 has a goat.

The flaw in your problem definition is the condition  "given that door 2 has a goat", it should be "given Monty opens Door 2"
.
If we call the 'probability that Monty opens Door 2', p(g2), then:
p(g2) = (1/3*1)  + (1/3 * 1/2)  + (1/3 * 0) = 1/2 and
p(g2)|(c1) = 1/2 and p(g2)|(c3) = 1

Plug those values into Bayes and you get 1/3 and 2/3

  • Index
  •  » Guestbook
  •  » Flaws in logic of solution to a couple of the logic problems

Board footer

Powered by FluxBB