Live data from Hacker News

Coding Horror: Finishing The Game

codinghorror.com

31–40 of 41 posts

Re: Coding Horror: Finishing The Game

#31
# The hard part: THIS IS AN 'A POSTERIORI' PROBLEM.

# The fact as ALREADY happened.

# BG/GB being DIFFERENT is NOT THE TWIST.

# Whether they are or not it will amount to 50% total.

# TWIST: BB is not possible.

  def boy_girl_problem():
    from random import choice

    families = {}
    for i in range(1000):
      families[i] = []
      families[i].append(choice(['BOY', 'GIRL']))
      families[i].append(choice(['BOY', 'GIRL']))
  
    had_both_sex = filter(lambda f: set(f) == set(['BOY', 'GIRL']), families.values())
    had_two_boys = filter(lambda f: 'GIRL' not in f, families.values())

    return len(had_both_sex) / float(len(families) - len(had_two_boys))
# average(boy_girl_problem) == 2/3

Re: Coding Horror: Finishing The Game

#32
post #27
post #23

Earlier quoted context omitted.

The difference is that you have specified that the child picked up from the police station is a girl, thus only the sex of the other child is unknown. This other child is either a boy or a girl, presumably with a 50/50 chance either way, resulting in a 50% chance of one being a boy and one being a girl. Concretely, using a capital letter to denote the sex of the child picked up from the station, there are only two po…

How much do you need to know about the person to know which child is which? I don't quite understand it, but apparently anything which can be used to distinguish the children will do. Possibilities with two children: Gg, Bg, Gb, Bb If one of them has a distinguishing mark, they have an apostrophe: (in jail, has red hair, or born first) G'g, B'g, G'b, B'b, Gg', Bg', Gb', Bb' Then note that the marked one is a girl: G'…

No, that is not it. With G'g and Gg' you are repeating the same permutation in your set above!

It makes no difference if they have distinguishing marks or not. It matters if you are told that a particular child is a girl (50%) or if you are only told that at least one child is a girl (66%).

Re: Coding Horror: Finishing The Game

#33
post #32
post #27

Earlier quoted context omitted.

How much do you need to know about the person to know which child is which? I don't quite understand it, but apparently anything which can be used to distinguish the children will do. Possibilities with two children: Gg, Bg, Gb, Bb If one of them has a distinguishing mark, they have an apostrophe: (in jail, has red hair, or born first) G'g, B'g, G'b, B'b, Gg', Bg', Gb', Bb' Then note that the marked one is a girl: G'…

No, that is not it. With G'g and Gg' you are repeating the same permutation in your set above! It makes no difference if they have distinguishing marks or not. It matters if you are told that a particular child is a girl (50%) or if you are only told that at least one child is a girl (66%).

How can you be told information about a particular child if you have no way to distinguish them?

I partially understand your point about G'g vs Gg' now: if having a prime is the only way to distinguish the children, then G and g must be indistinguishable, so G = g.

Re: Coding Horror: Finishing The Game

#34

Sorry Jeff, I understand the problem, but the language of the setup was wrong. Since a PERSON told you they have one girl, the GB and BG are equivalent and collapse to one case instead of two in the way that normal people talk . If you had said that a mathematician or a statistician said they have one girl, that would be a different story.

seano nailed the way I interpreted the (poorly-phrased) version of it:

"Both of my kids are driving me crazy! Just yesterday I had to pick one of them up from the police station--I grounded her for a month!" - given just the information in your quote, the odds are 50% of a boy and a girl.

http://news.ycombinator.com/item?id=416555

Re: Coding Horror: Finishing The Game

#35
post #33
post #32

Earlier quoted context omitted.

No, that is not it. With G'g and Gg' you are repeating the same permutation in your set above! It makes no difference if they have distinguishing marks or not. It matters if you are told that a particular child is a girl (50%) or if you are only told that at least one child is a girl (66%).

How can you be told information about a particular child if you have no way to distinguish them? I partially understand your point about G'g vs Gg' now: if having a prime is the only way to distinguish the children, then G and g must be indistinguishable, so G = g.

Think about it this way: I take two coins out of my pocket and hold them inside my hand so that neither of us has seen them. I show you the coin in my left hand and you see that it is tails, what are the odds of the coin in the other hand being heads? 50%. This is the chance of a head/tail combo in this case.

I now put the coins back into my pocket, shuffle them about, and again take them out inside my hands. This time I look inside both my hands, not letting you see, and tell you (truthfully) that at least one is tails. Given that information, you can deduce three mutually exclusive possibilities each of equal probability - both are tails, only the coin in my right hand is tails or only the coin in my left hand is tails. Hence we have the odds in this situation of 2/3 for a head/tail combo.

It is easy to see that the first situation is akin to knowing that a particular child is female, whilst the second is akin to knowing that at least one of the children is female. Also, in either case it does not matter if the coins are distinguishable - one could be a euro and the other a pound.

Re: Coding Horror: Finishing The Game

#36
post #14

I think that people are debating between 3 choices: (a) 100% chance that there is a boy and girl, (b) 2/3 chance that it is a boy and a girl, or (c) 50% chance that it is a boy and a girl. It depends very much on the exact wording of the problem. Like many people in the comments of Jeff's post said that if the person says that "one of my kids is a girl," then common sense makes it sound like ONLY one kid is a girl an…

http://paulbuchheit.blogspot.com/2009/01/question-is-wrong.h...

Re: Coding Horror: Finishing The Game

#37
post #26

The question is ill posed, because the anwser is highly dependent on how the couple told you that they have one girl. If they tell you "we have two kids", you ask them if at least one of them is a girl and they answer "yes", then indeed the probability of the other kid beeing a boy is 2/3. If they tell you "we have two kids, and one of them is a girl", then by all rules of rational discourse the probability for the o…

Yes! Here is more agreement:

http://paulbuchheit.blogspot.com/2009/01/question-is-wrong.h...

(and also my own comment from earlier:) http://news.ycombinator.com/item?id=416576

Re: Coding Horror: Finishing The Game

#38
post #23

Earlier quoted context omitted.

Can you give me your reasoning? I think the only conclusions you can get from that quote is that the person has two children, and at least one of those is a girl. Do you disagree with that? If I am correct about that, then it matches the conditions discussed in the article and the answer would be 2/3 for a boy and a girl.

The difference is that you have specified that the child picked up from the police station is a girl, thus only the sex of the other child is unknown. This other child is either a boy or a girl, presumably with a 50/50 chance either way, resulting in a 50% chance of one being a boy and one being a girl. Concretely, using a capital letter to denote the sex of the child picked up from the station, there are only two po…

No, I don't think the label "picked up from a police station" affects the problem the way you are thinking. What I believe you are not accounting for is that there are twice as many mixed families in the population as there are pure girl families.

Take 1000 two-child families (so as to intuitively ignore fluctuations). Families 1-250 are girl-girl, 251-500 had a girl then a boy, and 501-750 had a boy then a girl. Any of those 750 families could have made the quote in my post, yet there are 500 families with boy-girl, and 250 with girl-girl.

Or another example that I think speaks more directly to your post: you see a woman with a T-shirt reading "Proud Mother of Two" next to a girl who is obviously her daughter. What is the probability of her other child being a boy? Again, since there are twice as many mixed families as pure girl families, the odds are 2/3.

Re: Coding Horror: Finishing The Game

#39
post #31

# The hard part: THIS IS AN 'A POSTERIORI' PROBLEM. # The fact as ALREADY happened. # BG/GB being DIFFERENT is NOT THE TWIST. # Whether they are or not it will amount to 50% total. # TWIST: BB is not possible. def boy_girl_problem(): from random import choice families = {} for i in range(1000): families[i] = [] families[i].append(choice(['BOY', 'GIRL'])) families[i].append(choice(['BOY', 'GIRL'])) had_both_sex = filt…

# Here's a less crude rewrite

# It reflects conditional probability better

  def boy_girl_problem():
    from random import choice

    families = {}
    for i in range(1000):
      families[i] = []
      families[i].append(choice(['BOY', 'GIRL']))
      families[i].append(choice(['BOY', 'GIRL']))
  
    had_both_sex = filter(lambda f: set(f) == set(['BOY', 'GIRL']), families.values())
    had_one_girl = filter(lambda f: 'GIRL' in f, families.values())

    return len(had_both_sex) / float(len(had_one_girl))

Re: Coding Horror: Finishing The Game

#40
post #23

Earlier quoted context omitted.

The difference is that you have specified that the child picked up from the police station is a girl, thus only the sex of the other child is unknown. This other child is either a boy or a girl, presumably with a 50/50 chance either way, resulting in a 50% chance of one being a boy and one being a girl. Concretely, using a capital letter to denote the sex of the child picked up from the station, there are only two po…

No, I don't think the label "picked up from a police station" affects the problem the way you are thinking. What I believe you are not accounting for is that there are twice as many mixed families in the population as there are pure girl families. Take 1000 two-child families (so as to intuitively ignore fluctuations). Families 1-250 are girl-girl, 251-500 had a girl then a boy, and 501-750 had a boy then a girl. Any…

"Or another example that I think speaks more directly to your post: you see a woman with a T-shirt reading "Proud Mother of Two" next to a girl who is obviously her daughter. What is the probability of her other child being a boy? Again, since there are twice as many mixed families as pure girl families, the odds are 2/3."

The odds are 50%, do you seriously think different?

Your mistake is that in families 1-250 the girl next to the mother could be either daughter.

In families 1-750 there are 1000 daughters, the daughter standing next to the mother is equally likely to be any of those and half have brothers, half have sisters.

Post reply on HN