Hacker News new | ask | show | jobs
by RiderOfGiraffes 5830 days ago
Your first error is here:

  P(BH or RH) = 1
This is supposed to be the probability without conditionals, in which case P(BH or RH) = 3/4. Using the Bayesian formula is what is taking into account the fact that at least one head has shown.

Your second error is here:

    P( blue_head ) * P( red_head ) (independent events)
    = 1/4 * 1/4
That's probably a typo, because you probably know that P(BH)=1/2.

Your third error is here:

    1/4 * 1/4 = 1/2
1/4 * 1/4 = 1/16

Even if you correct this to the 1/2 * 1/2 that you intended, you now get that P(BH and RH)=1/4. Surely you realise that this must be wrong. I've already told you that there's at least one head, so you can't get the same answer as when I've given you no information.

Here's the correct Bayesian sum:

    P(RH and BH | RH or BH)
  = P(RH and BH and (RH or BH)) / P(RH or BH)
  = P(RH and BH) / (3/4)
  = P(RH) * P(BH) / (3/4)
  = 1/2 * 1/2 / (3/4)
  = 1/4 / (3/4)
  = 1/3
The fact that I'm using the conditional probability is what uses the information I've given you, so you can't use that again and claim P(RH or BH)=1.

Show me the error.

Here, do an experiment. Toss two coins of different denominations. Consider those cases where there's at least one head. How often are they both heads? Are you a programmer? Run the simulation - show me the code.

Here, let me help:

  #!/usr/bin/python

  import random

  def toss():
    if random.random() <= 0.5:
      return 'Head'
    return 'tail'

  trials = 0
  two_heads = 0

  for trial in xrange(10000):

    coin0 = toss()
    coin1 = toss()
    if coin0 != 'Head' and coin1 != 'Head':
        continue
    trials += 1
    if coin0 == 'Head' and coin1 == 'Head':
      two_heads += 1

  print trials,float(two_heads)/trials