Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Irish Times - Probability Question

  • 04-06-2012 11:39AM
    #1
    Registered Users, Registered Users 2 Posts: 520 ✭✭✭


    http://www.irishtimes.com/newspaper/finance/2012/0604/1224317198188.html

    Q: You have a jar with three coins in it, two of the coins are regular heads and tails, but the third coin has a head on both sides. You dip in and pick a coin at random, toss it three times, and given that each time you get a head, what’s the probability when you toss for a fourth time it will be another head?

    A: 90%



    Can anybody show the maths on this answer?


Comments

  • Registered Users, Registered Users 2 Posts: 1,163 ✭✭✭hivizman


    This is a classic application of Bayes' Theorem. We need to calculate the probability of throwing a head, given that we have (a) selected at random one of three coins, of which two - A1 and A2 - have a head and a tail, and the other - B - has two heads; and (b) thrown the selected coin three times, each time showing a head.

    If we select either A1 or A2, the probability of throwing three heads is 1/2 x 1/2 x 1/2 = 1/8 for both coins. There is a probability of 2/3 for selecting either A1 or A2, so the probability of throwing three heads, given that we have selected one of the fair coins A1 or A2, is 1/8 x 2/3 = 1/12.

    If we select B, then we must throw three heads, so the probability of throwing thres heads, given that we originally selected coin B is the same as the probability of selecting coin B, which is 1/3 or 4/12.

    Now the probability that we originally selected either A1 or A2, given that we have thrown three heads, is (1/12)/(1/12 + 4/12) = 1/5.

    The probability that we originally selected B, given that we have thrown three heads, is (4/12)/(1/12 + 4/12) = 4/5.

    If we originally selected either A1 or A2, there is a 1/2 probability that we will get a head on the fourth throw, while if we originally selected B, we must get a head on the fourth throw.

    So the overall probability of a head on the fourth throw is:

    1/5 x 1/2 + 4/5 x 1 = 9/10 = 90%.


  • Registered Users, Registered Users 2 Posts: 14 JustACitizen


    I saw that too and I don't see how 90% is correct - as far as I can see, it should be 3/5 or 60%.

    This is how I calculate it: first, the thing about throwing 3 heads before the fourth toss is a red herring: each toss is an independent event so the previous 3 tosses shouldnt affect the fourth one. As I see it, there are two events:

    1. pick a random coin from the jar: it can be a normal heads/tails coin or else a double-headed coin
    2. toss whatever coin you've got

    Counting probabilities like described here http://gwydir.demon.co.uk/jo/probability/info.htm gives all the possible outcomes like this:

    N=normal head/tail coin
    DH=double-headed coin

    PICK Toss Result

    N#1 H
    N#1 T
    N#2 H
    N#2 T
    DH H

    That gives 5 possible outcomes with 3 of them resulting in heads. So the probability is 3/5 or 60%.

    Where did I go wrong?


  • Registered Users, Registered Users 2 Posts: 14 JustACitizen


    hivizman wrote: »
    This is a classic application of Bayes' Theorem. We need to calculate the probability of throwing a head, given that we have (a) selected at random one of three coins, of which two - A1 and A2 - have a head and a tail, and the other - B - has two heads; and (b) thrown the selected coin three times, each time showing a head.

    If we select either A1 or A2, the probability of throwing three heads is 1/2 x 1/2 x 1/2 = 1/8 for both coins. There is a probability of 2/3 for selecting either A1 or A2, so the probability of throwing three heads, given that we have selected one of the fair coins A1 or A2, is 1/8 x 2/3 = 1/12.

    If we select B, then we must throw three heads, so the probability of throwing thres heads, given that we originally selected coin B is the same as the probability of selecting coin B, which is 1/3 or 4/12.

    Now the probability that we originally selected either A1 or A2, given that we have thrown three heads, is (1/12)/(1/12 + 4/12) = 1/5.

    The probability that we originally selected B, given that we have thrown three heads, is (4/12)/(1/12 + 4/12) = 4/5.

    If we originally selected either A1 or A2, there is a 1/2 probability that we will get a head on the fourth throw, while if we originally selected B, we must get a head on the fourth throw.

    So the overall probability of a head on the fourth throw is:

    1/5 x 1/2 + 4/5 x 1 = 9/10 = 90%.

    Hmmm...interesting. So this must be the accepted answer then. I still don't see why the fourth toss shouldn't be considered an independent event (as I mentioned in my reply above). I would understand if the question was posed as the probability of tossing 4 heads in a row. Is this just the difference between the 2 interpretations of Bayes (Bayesian interpretation, it expresses how a subjective degree of belief should rationally change to account for evidence: this supports the 90% vs frequentist interpretation)? Havent time to read full description of the theorem so I may be misunderstanding....


  • Registered Users, Registered Users 2 Posts: 1,163 ✭✭✭hivizman


    I saw that too and I don't see how 90% is correct - as far as I can see, it should be 3/5 or 60%.

    This is how I calculate it: first, the thing about throwing 3 heads before the fourth toss is a red herring: each toss is an independent event so the previous 3 tosses shouldnt affect the fourth one. As I see it, there are two events:

    1. pick a random coin from the jar: it can be a normal heads/tails coin or else a double-headed coin
    2. toss whatever coin you've got

    Counting probabilities like described here http://gwydir.demon.co.uk/jo/probability/info.htm gives all the possible outcomes like this:

    N=normal head/tail coin
    DH=double-headed coin

    PICK Toss Result

    N#1 H
    N#1 T
    N#2 H
    N#2 T
    DH H

    That gives 5 possible outcomes with 3 of them resulting in heads. So the probability is 3/5 or 60%.

    Where did I go wrong?

    Actually, there should be six possible outcomes in the table above:

    N#1 H
    N#1 T
    N#2 H
    N#2 T
    DH H (side 1)
    DH H (side 2)

    Counting the multiple outcomes for the double head coin is crucial.

    The key point (which is where Bayes' Theorem comes in) is that the information that you have just thrown three heads with your chosen coin makes it more likely that you chose the double head coin in the first place. If you originally chose one of the normal coins, you could have thrown one or more tails, but this is impossible with the double head coin. So each of the eight ways in which a coin can land in three throws (HHH, HHT, HTH, HTT, THH, THT, TTH, TTT) would be HHH for a double head coin. There is only one possible sequence, HHH, from the double head coin, but you can get that sequence in eight different ways, depending on which side lands face up on each throw.

    That means that a normal coin has a 1/8 chance of giving HHH in three throws while a double head coin has an 8/8 chance of giving HHH. A list of the 3 x 8 = 24 possible outcomes would include eight HHH from the double head coin and one HHH from each of the two normal coins. So, if you throw your random coin three times and get HHH, the probability that you originally chose the double head coin rises from 1/3 to 4/5.

    Having read the original article where the question appears, I think that the main point of questions like this in a job interview isn't getting the right answer but being able to reason your way through the problem towards a plausible answer. And questions like this at job interviews are by no means a recent phenomenon - I remember being interviewed a long time ago by someone who said: "You're a maths student - so tell me how many zeroes there are at the end of 100! [100 factorial]".


  • Registered Users, Registered Users 2 Posts: 520 ✭✭✭Yenwod


    I really liked probability in the LC but that was many years ago. Very rusty clearly because that all hurt my head, haha. Thanks though, going to read through it all again...slowly


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 14 JustACitizen


    hivizman wrote: »
    Actually, there should be six possible outcomes in the table above:

    N#1 H
    N#1 T
    N#2 H
    N#2 T
    DH H (side 1)
    DH H (side 2)

    Counting the multiple outcomes for the double head coin is crucial.

    Good point - I missed that.
    The key point (which is where Bayes' Theorem comes in) is that the information that you have just thrown three heads with your chosen coin makes it more likely that you chose the double head coin in the first place.

    I see - that's my main mistake alright. I was thinking of the simple point that throwing 9 heads with a normal coin doesn't change the fact that the probability of a head on the tenth throw is still 50%. I suppose the difference here is that, in the original question, the picking of the coin is a different event to the tossing of it where the ten tosses are the "same" (albeit independent), just repeated, event. So, in the explanation of Bayes' theorem on wikipedia, the coin pick correspond to "evidence". Hmmm, can't say I fully comfortable with it, but I can understand it in these terms.
    If you originally chose one of the normal coins, you could have thrown one or more tails, but this is impossible with the double head coin. So each of the eight ways in which a coin can land in three throws (HHH, HHT, HTH, HTT, THH, THT, TTH, TTT) would be HHH for a double head coin. There is only one possible sequence, HHH, from the double head coin, but you can get that sequence in eight different ways, depending on which side lands face up on each throw.

    That means that a normal coin has a 1/8 chance of giving HHH in three throws while a double head coin has an 8/8 chance of giving HHH. A list of the 3 x 8 = 24 possible outcomes would include eight HHH from the double head coin and one HHH from each of the two normal coins. So, if you throw your random coin three times and get HHH, the probability that you originally chose the double head coin rises from 1/3 to 4/5.

    Good explanation. Had to read it a few times to see where you got 4/5 though. For the slow (like myself), its (eight HHH from the double head coin)/(eight HHH from the double head coin and one HHH from each of the two normal coins) = 8/(8+1+1) = 4/5
    Having read the original article where the question appears, I think that the main point of questions like this in a job interview isn't getting the right answer but being able to reason your way through the problem towards a plausible answer. And questions like this at job interviews are by no means a recent phenomenon - I remember being interviewed a long time ago by someone who said: "You're a maths student - so tell me how many zeroes there are at the end of 100! [100 factorial]".

    Agreed. I'm skeptical about these kinds of interviews but I suppose it beats asking people the details of the pack of lies they've filled their CV with.....!

    Thanks for explanation


  • Registered Users, Registered Users 2 Posts: 1,163 ✭✭✭hivizman


    Good explanation. Had to read it a few times to see where you got 4/5 though. For the slow (like myself), its (eight HHH from the double head coin)/(eight HHH from the double head coin and one HHH from each of the two normal coins) = 8/(8+1+1) = 4/5.

    This last bit is exactly Bayes' Theorem!

    More formally, Bayes' Theorem states that:

    P(A|B) = P(B|A) x P(A)/P(B) [P(A|B) is the conditional probability of event A occurring conditional on event B occurring].

    If we define the event A as choosing the double-headed coin, and the event B as throwing three heads, then we are trying to calculate the probability that we chose the double-headed coin given that we have thrown three heads.

    But P(B|A), the probability that we throw three heads given that we chose the double-headed coin, is 1 (if we chose the double-headed coin, we must throw three heads), P(A), the probability that we initially chose the double-headed coin, is 1/3 or 8/24, and P(B), the probability that we throw three heads, is (8 + 1 + 1)/24 or 10/24. [The denominator is 24 because there is a choice of three coins, each of which can be thrown three times in eight different ways].

    So P(A|B) = (8/24)/(10/24) = 8/10 = 4/5.


  • Registered Users, Registered Users 2 Posts: 14 JustACitizen


    hivizman wrote: »
    This last bit is exactly Bayes' Theorem!

    More formally, Bayes' Theorem states that:

    P(A|B) = P(B|A) x P(A)/P(B) [P(A|B) is the conditional probability of event A occurring conditional on event B occurring].

    If we define the event A as choosing the double-headed coin, and the event B as throwing three heads, then we are trying to calculate the probability that we chose the double-headed coin given that we have thrown three heads.

    But P(B|A), the probability that we throw three heads given that we chose the double-headed coin, is 1 (if we chose the double-headed coin, we must throw three heads), P(A), the probability that we initially chose the double-headed coin, is 1/3 or 8/24, and P(B), the probability that we throw three heads, is (8 + 1 + 1)/24 or 10/24. [The denominator is 24 because there is a choice of three coins, each of which can be thrown three times in eight different ways].

    So P(A|B) = (8/24)/(10/24) = 8/10 = 4/5.

    Ah, I see. The equation makes this easier.

    Well, I've learned something out of this: part of it is how to calculate the probabilities of the various components of the problem but, most importantly, the fact that one of those components is P(A|B) and how that plugs into the overall solution.

    Understanding the solution now, this strikes me as a very hard interview question. I'd be surprised if many Google applicants would know Bayes' theorem off the top of their head (maybe Susquehanna applicants might) and coming up with a decent attempt at explaining how you might solve it without that knowledge would be almost impossible. I suppose stating the principle of the theorem without knowing how to caculate the result should get you most of the way there.


  • Registered Users, Registered Users 2 Posts: 1,163 ✭✭✭hivizman


    Understanding the solution now, this strikes me as a very hard interview question. I'd be surprised if many Google applicants would know Bayes' theorem off the top of their head (maybe Susquehanna applicants might) and coming up with a decent attempt at explaining how you might solve it without that knowledge would be almost impossible. I suppose stating the principle of the theorem without knowing how to caculate the result should get you most of the way there.

    Yes, I agree that this would be a hard question to answer in an interview (particularly without pen and paper), even if you knew the underlying mathematics. But if the interviewer took you through the various stages of the calculation, you would probably get there.

    The key concept, I think, is that getting three heads in a row from tossing your randomly selected coin provides information that changes the probabilities you attach to selecting the three coins. Initially, each coin is equally likely to be chosen at random, so the prior probability of selecting each coin is 1/3. With the additional informatiion, you can replace the prior probabilities with posterior probabilities of 80% (4/5) for the double-headed coin and 10% (1/10) for each of the two normal coins. This is itself a specific instance of how information can change the way we look at a situation (indeed, if data do not change our prior probabilities, then they don't count as genuine information).


  • Closed Accounts Posts: 11,001 ✭✭✭✭opinion guy


    hivizman wrote: »
    "You're a maths student - so tell me how many zeroes there are at the end of 100! [100 factorial]".

    My answer: No!


  • Advertisement
  • Closed Accounts Posts: 4,204 ✭✭✭FoxT


    you can come up with a lower bound very fast though,

    10.20.30.40.50.60.70.80.90.100 will have 11 zeroes,

    then you have

    4.5
    6.15
    8.25
    12.35
    ...up to 95
    etc all of which add a zero each.

    so quick estimate at lower bound is 21.

    Now, because the only factors of 10 are 2 & 5, I'd say that 21 is not just the lower bound, but the actual answer. Couldn't swear to it though.

    If you gave me that much at an interview I'd write you down as being capable...


  • Moderators, Science, Health & Environment Moderators Posts: 1,852 Mod ✭✭✭✭Michael Collins


    FoxT wrote: »
    you can come up with a lower bound very fast though,

    10.20.30.40.50.60.70.80.90.100 will have 11 zeroes,

    then you have

    4.5
    6.15
    8.25
    12.35
    ...up to 95
    etc all of which add a zero each.

    so quick estimate at lower bound is 21.

    Now, because the only factors of 10 are 2 & 5, I'd say that 21 is not just the lower bound, but the actual answer. Couldn't swear to it though.

    If you gave me that much at an interview I'd write you down as being capable...

    Yeah this is definately the way to go with this one, just watch out for numbers with two factors of 'five' because:

    8.25 = 200 i.e. two zeros.

    So the numbers 25, 50 and 75 need to be counted twice due to their multiplicity of 'five' factors. This brings the number up to 24 (which is correct).

    (You'll always have enough 'two' factors to pair with these 'fives' since you have a 'two' factor every second number, and a 'five' factor only every, eh...fifth number).

    For the doubting among you, Maple gives:

    100! = 93326215443944152681699238856266700490715968264381621468592963895217599993229915608...
    ...941463976156518286253697920827223758251185210916864000000000000000000000000


  • Registered Users, Registered Users 2 Posts: 5,141 ✭✭✭Yakuza


    My first guess was 21, but I forgot about the extra factors of 5 in 25, 50 and 75 :o


  • Registered Users, Registered Users 2 Posts: 5,141 ✭✭✭Yakuza


    hivizman wrote: »
    This last bit is exactly Bayes' Theorem!

    More formally, Bayes' Theorem states that:

    P(A|B) = P(B|A) x P(A)/P(B) [P(A|B) is the conditional probability of event A occurring conditional on event B occurring].

    If we define the event A as choosing the double-headed coin, and the event B as throwing three heads, then we are trying to calculate the probability that we chose the double-headed coin given that we have thrown three heads.

    But P(B|A), the probability that we throw three heads given that we chose the double-headed coin, is 1 (if we chose the double-headed coin, we must throw three heads), P(A), the probability that we initially chose the double-headed coin, is 1/3 or 8/24, and P(B), the probability that we throw three heads, is (8 + 1 + 1)/24 or 10/24. [The denominator is 24 because there is a choice of three coins, each of which can be thrown three times in eight different ways].

    So P(A|B) = (8/24)/(10/24) = 8/10 = 4/5.


    I took a slightly different approach, same result though :)
    Let:
    P(4) = probability of getting 4 heads in a row = 2/3*1/16 + 1/3*1 = 18/48
    P(3) = probability of getting 3 heads in a row = 2/3*1/8 + 1/3*1 = 10/24 = 20/48

    Each P(N) is the weighted average of probabilities of getting N heads with a regular coin and the double-headed coin.

    so, Bayes' Theorem states:

    P(4|3) = P(3|4) * P(4) / P(3)

    P(3|4) is 1 as the probabilty of getting 3 heads thrown in a row given 4 heads were thrown in a row is a certainty :)

    So: P(4|3) = 1 * (18/48) / (20/48) = 0.9 as before.


  • Registered Users, Registered Users 2 Posts: 1,163 ✭✭✭hivizman


    Yeah this is definately the way to go with this one, just watch out for numbers with two factors of 'five' because:

    8.25 = 200 i.e. two zeros.

    So the numbers 25, 50 and 75 need to be counted twice due to their multiplicity of 'five' factors. This brings the number up to 24 (which is correct).

    (You'll always have enough 'two' factors to pair with these 'fives' since you have a 'two' factor every second number, and a 'five' factor only every, eh...fifth number).

    For the doubting among you, Maple gives:

    100! = 93326215443944152681699238856266700490715968264381621468592963895217599993229915608...
    ...941463976156518286253697920827223758251185210916864000000000000000000000000

    That's basically how I worked out the answer in the interview. I noted that you need a factor of 2 and a factor of 5 to give a zero, that there are clearly more factors of 2 than factors of 5, and that 5 times 20 = 100, so my initial answer was 20.

    But then the interviewer's body language made it clear that this wasn't the answer, so I thought a bit more and realised that each multiple of 25 (5^2) contributed two factors of 5, so there were another four factors from 25, 50, 75 and 100, giving the total of 24.

    I got the job, but in four years I never had to do more than basic arithmetic and drawing a few graphs.


Advertisement