I was a mathematician, and now work in finance (systematic trading). I've found a reasonable negative filter is`````` A jar has 1000 coins, of which 999 are fair and 1 is double headed. Pick a coin at random, and toss it 10 times. Given that you see 10 heads, what is the probability that the next toss of that coin is also a head? `````` That tests their ability to turn a problem into mathematics, and some very basic conditional probability. Another common question (that I don't use myself) is to ask what happens to bond prices if interest rates go up.

 That's a nice filter. (Of course, I'm a former mathematician as well.) Here's how I think of it:- the prior odds that you picked the double-headed coin are 1/999.- after seeing ten heads, the posterior odds that you picked the double-headed coin are (2^10)/999 - let's approximate this as 1. (Bayes' theorem usually gets expressed in terms of probabilities, but it's so much simpler in terms of odds.)- so it's roughly equally likely that you have the double-headed coin or any non-double-headed coin; the probability of flipping an eleventh head is then approximate (1/2)(1) + (1/2)(1/2) = 3/4.
 For the interested, some links to Bayes' theorem: http://en.wikipedia.org/wiki/Bayes'_theoremhttp://yudkowsky.net/rational/bayesUseful if you want to know (or need a good way to explain) what a posterior probability is and how it's different from a prior probability
 I vastly prefer Bayes Theorem as ratios vs. percentages (plug, wrote about it here: http://betterexplained.com/articles/understanding-bayes-theo...)I like a "factor label" style approach where you can see the prior probability (Fair: Biased), the information about the flips, and the posterior probability (the revised chances after the new information is taken into account):Prior * Information = Posteriorso(Fair : Biased) * (10 Fair heads : Fair ) : (10 Biased heads : Biased) = 10 Fair Heads : 10 Biased HeadsPlugging in, we'd have:(999 / 1) * (1 / 1024 ) / (1 / 1) = 999 / 1024The odds are ever-slightly in favor of a biased coin. So we can mentally guess ever-slightly above 3/4 for the chance of another heads. We could write (999/2 + 1024) / (999 + 1024) on the whiteboard to be exact.
 Why is it 1/999? Shouldn't it be 1/1000 since there are 1000 total coins?
 Odds, not probability. Probability p means odds of p:(1-p) or, if you prefer writing it as a fraction, p/(1-p).(Note 1. The odds of a thing are the ratio Pr(thing) : Pr(not thing). You can generalize this to any mutually exclusive and exhaustive set of things: the odds are the ratio of the probabilities. The fact that there may therefore be more than 2 such things is the reason why I prefer not to turn odds into fractions as above.)(Note 2. Bayes' theorem is, as others have mentioned, much nicer when you work with odds rather than probabilities for your prior and posterior probabilities. If you're comfortable with logarithms, it's nicer still when you work with logarithms of odds. Now you're just adding the vector of log-likelihoods to the prior odds vector to get the posterior odds vector. Which is how I think of the question above, at least if I'm allowed to be sloppy and imprecise. You start with almost exactly 10 bits of prior prejudice for "fair" over "two-headed", then you get exactly 10 bits of evidence for "two-headed" over "fair", at which point those cancel out almost exactly so you should assign almost equal probabilities to those two possibilities.)
 That makes sense. I've never dealt with odds as a fraction before.
 Can you elaborate on the posterior calculation of (2^10)/999?
 Sure. In terms of odds, Bayes' theorem says(posterior odds) = (prior odds) * (likelihood ratio)The prior odds are 1/999, so we need to show that the likelihood ratio is 2^10.The likelihood ratio is the probability of seeing 10 heads from a double-headed coin divided by the probability of seeing 10 heads from a fair coin, which is 1/((1/2)^10) or 2^10.
 0.7531 if you don't assume that 2^10 = 999
 Should I parse it as tossing the same coin 10 times, or choosing from the jar 10 times?
 Good question, and one that sometimes comes up when I ask it in interviews. You are tossing the same coin 10 times.
 0.753?A the beginning, there's a 1/1000 chance that you pick a double-headed, and a 999/1000 chance you pick a fair coin.A fair coin would act the way you've observed 1/1024 times. A double-headed coin would act that way 100% of the time.(This is where I get fuzzy): Given what you've observed, there is a (1000+1024)/1024 = 0.506 chance that the coin is double-headed. There is a 0.494 chance that it's fair.A double-headed coin would come up heads next 100% of the time. A fair coin would come up heads 50% of the time. So, 0.506 x 1 + 0.494 x 0.5 = 0.753.How far off am I?
 Your .506 is right but the arithmetic problem that you set equal to it is wrong. I think you meant to type 1024/(1024+1000). (BTW, it should be 1024/(1024+999) ).
 Close enough for beta. We'll refine after user testing. (Guess my specialty!)
 This is a fun question. Can I look at the coin's two sides? If not...I assume you now have to start applying statistical tests (given that a fair coin will only do this once out of 1024 times, what are the chances I've got one of those 999 coins vs the 1/1000 chance that I picked the double headed coin?) or is there some simplifying assumption I'm missing.Anyway--assume I think all that aloud in an interview. What does that tell you about the candidate?
 >Can I look at the coin's two sides?I would give points for just asking that question, because many people bound by conventional thinking wouldn't dare to ask it, accepting default assumption that you can't. I'm not saying this says anything about your ability to solve the problem, but asking the question is a good sign of a supple mind.
 You can only see the result of the flips, you can't examine the coin. Yes, it comes down to estimating the probability of having a biased coin given that you have seen it come up heads ten times in a row.
 0.5005?
 That's what I got.There's a .999 chance you have a fair coin and a .001 chance you have the rigged coin.(0.999 * 0.5) + (0.001 * 1) = 0.5005.Seems too simple, but a coin is a coin, right?
 Ask yourself a question: can you use the data (the 10 coin tosses) to update the probability of the current coin being two-headed?
 I wouldn't use the data. The coin hasn't changed since I picked it out of the jar. If I flip it 1, 10, or 10e100 times, the coin would still be the same coin.So figure the p(heads) for the coin and ignore the previous history. Overthinking it is why this makes a good FizzBuzz problem.
 An example that should show this approach is wrong:Suppose that the jar contains 500 double-head coins and 500 double-tail coins. You pull a coin from the jar, flip it 10 times, and get 10 heads. What is the probability it will come up heads next time?
 That seems like a completely different problem to me, since all randomness is out of the system the moment you see the first flip.
 OK, so now imagine that there are 1000000 double-headed coins, 1000000 double-tailed coins, and one fair coin. Now (1) there's still (potentially) randomness present, so it's not "completely different" from the original problem, but (2) the ignore-the-data approach gives an obviously wrong answer whereas using the data gives a believable answer.
 Let's consider that it might be a fair coin, or it might be a double-headed coin.Let's also say that every time you flip the coin and it comes up tails, you win \$5. And every time you flip the coin and it comes up heads, you lose \$1.Clearly, this would be a great game to have the opportunity to play, if the coin is fair. Every time you flip you either win \$5 or lose \$1, so your profit, on average, is \$4 per flip.You've flipped it 10 times so far, and it's come up heads every time, and you've lost \$10.After you're \$10, \$100, \$1000, or \$10e100 in the red, without ever seeing a win, when do you change your mind about playing this game?
 You are getting downvotes because you didn't follow Bayesian reasoning, but there is some justification for your instincts here http://www.stat.columbia.edu/~gelman/research/unpublished/ph...
 Yes, it's still the same coin, but you don't know which coin you got. You know that you got 10 consecutive heads though. How improbable this is if you got a fair coin? How probable this is with the double-head coin? This is the data you can use to update the probability.
 So if you flipped the coin twice, once it was tails, and once it was heads... you'd ignore that info? Or look at it another way, if you flipped it a million times and it always came up heads...
 I've used a similar question, but with two coins. I think if I am ever in a position where I am hiring again, I may follow-up that question with this extension to 100 coins.What is the most common answer? Typically, I get either blank stares or a gut answer of just a little over 50%. I find that physics people are pretty good at solving the problem.I would also REALLY hope that somebody who is applying for a job in finance understands the bond prices and interest rates, but I suppose that does make it a good fizz buzz type question.
 > I would also REALLY hope that somebody who is applying for a job in finance understands the bond prices and interest rates.You'd be surprised at how many people can't answer instantly. Or how many people can't give a convincing description of what a share is, and what rights it gives you.These are all easy questions, which to my mind is the point. The fact that someone can answer them doesn't tell you much, but if someone can't answer them then you need to think very hard about whether to hire them.
 The Monty Hall problem (or a subtle variant) is also great one to watch people work through. It's a chance to see if people can thing about probability in a sort of asymptotic way.Basically (if they get stuck), ask them how they would choose if there were actually a 100 doors, but the same rules apply. Obviously, everyone switches. What about 99? 98? ... turns out, 3 doors is the smallest number where the strategy is optimal. But when the number is large, the answer is much more obvious.
 The Tuesday boy problem is a little less known: http://mikeschiraldi.blogspot.com/2011/11/tuesday-boy-proble...
 I don't get it, even after the explanation. What's the mechanism that constrains those probabilities?
 You should be able to convince yourself that the conclusion is correct by writing a quick script to run a simulation with a million or so iterations. Actually understanding the reasoning intuitively is more challenging, but I think the linked article has a good explanation (the part about how the manner in which we receive information is as important as the information itself): http://scienceblogs.com/evolutionblog/2011/11/08/the-tuesday...
 That helps, thank you.
 The problem with asking Monty Hall in an interview is that ~75% of candidates already know the answer.
 Assume they already know it, and ask them to explain it. A good explanation is almost as rare as understanding it.If they don't know it, then ask to solve.The early controversy with the Monty Hall problem was that explanations left loopholes, or weren't compelling enough, and even people who who should have known better didn't understand the solution clearly enough.
 Yeah, because it's in every easy undergrad stats textbook.The problem with asking trick questions in an interview is that, although they may make the interviewer look smart, they are orthogonal to the ability to do the job. It's better to ask how to solve a current, pressing problem and see what questions the candidate asks. It's the questions that elucidate thinking style. Also, it's crowdsourcing and you can attribute or blame the candidate as the case maybe.The other part is getting along, so if an interview doesn't include something fun, it's all boring formality that doesn't allow anyone to get to know each other. Take them to a normal lunch if possible, because much more is learned by how people eat.
 There are tons of variations and few people know them.For instance ask "What if the showman didn't know which door the car was behind?"IIRC even if you exclude instances where the showman shows a car, it evens out the odds.
 And if they didn't, they would probably get it wrong even if they're experienced statisticians.
 One issue I have with Monty Hall problem as an interview question is that the problem statement is too subtle, with several hidden assumptions. Interviewers often end up posing a different puzzle without realizing just by using a slightly different language to pose it.
 That's true, the rules really do have to be laid out in plain language to be a fair question.
 Not only that, the problem statement has to be written down somewhere. I have gotten burnt in the past with problem statements changing along the way.
 Depressing, just asked my coworkers this and can't convince them it isn't an independent event :(.
 My wife and I have discussed this, and get a different answer to a few of the solutions we then googled for. I think it is as simple as: http://pastebin.com/gg5DTySG
 I'm thinking this: http://pastebin.com/GW1hTXwD Dying to know if I made it through the math FizzBuzz :)
 There is a mistake in the deduction in the second sentence. The chance that you picked the fair coin is approximately 49% not 1/1024.
 This is the simplest explanation, thank you.
 Given that this is hacker news, I'm surprised that no one bothered to write a simulation to sanity-check their answer. Here's a quick and dirty one: http://jsfiddle.net/qc9qk/2/The mistake that most people seem to be making is using P(biased) and P(fair) instead of P(biased|10 heads) and P(fair|10 heads).Spoiler: The answer is ~0.75.
 The bond prices question is a pretty bad filter, since it doesn't give the competent candidate much chance to express how they think, and a weak candidate has a good chance of guessing "they go down" and even a fair chance of blustering their way through followup questions/explanations.On the flip side, you could probably unintentionally trip up someone with a generally competent grasp of economics/stats but a lack of specific interest in bonds over terminology if your followup questions start asking them to distinguish between types of yield.Same with exchange rates (although I do remember back in school in a competitive presentation being complemented on my confident and plausible sounding explanation of the effect of an interest rate rise on exchange rates that also happened to be the reverse of the correct answer :-) )
 mumble mumble bayes mumble mumble I'll show myself out.
 related problem:a population has a 10% incidence of condition X. A test exists that is 90% accurate.1) What is the expected percentage of positive test results? 2) if a person tests positive, what is the probability that they actually have the condition? 3) if a person tests negative, what is the probability that they are actually free of the condition?
 By "90% accurate", you mean "10% false positive rate and 10% false negative rate", correct?
 correct, I should have made that explicit
 [deleted]
 But it's very likely that you picked a fair coin to start with, because most of the coins are fair. How do you compensate for that?
 with 1025 coins the numbers are nice:1024/1025 * 1/1024 = 1/1025 (probability of unbiased coin, 10 heads) 1/1025 (probability of biased coin & 10 heads) relative probability = .5 the answer is then precisely 3/4
 Do you mind posting a simple walkthrough for the answer
 Sure. The slick answer isThe chance of picking the biased coin is 1/1000. The chance of seeing 10 heads from a fair coin is (1/2)^10 = 1/1024. These are nearly equal, so given that you've seen 10 heads, there is a 50/50 chance of having a biased coin. So the probability the next flip shows a head is`````` P(H) = P(biased) * P(H|biased) + P(fair) * P(H|fair) = 0.75 `````` The long answer -Yo want to figure out P(biased | 10H). Using Bayes rule this is`````` P(biased | 10H) = P(10H | biased) * P(biased) / P(10H) = P(10H | biased) * P(biased) / (P(10H|biased) * P(biased) + P(10H|fair) * P(fair)) = 1 * (1/1000) / (1 * 1/1000 + 1/1024 * 999/1000) ~ 0.5 `````` and you now compute the probability of the next toss being a head as above.
 Isn't the gotcha of this test the fact that the history of previous coin flips has no effect on the next flip, given a fair coin?The OP is only asking what the outcome of the NEXT flip is, not the probability of flipping 11 heads in a row. Or did I read this wrong?
 "If you flipped 10 heads in a row the probability of the coin you have being the double heads coin increases dramatically..."I disagree. The coin is the coin. It didn't magically transport itself or change state after flipping it 10, 100, or a billion times.Lets change the puzzle to the simplest state: you pull a coin from the 1000-coin jar and flip it just once. What's the probability of heads?This is why roulette and baccarat tables in Vegas have those signs showing previous outcomes. It's meant to mess with your head. Previous history has no effect on future outcomes. A fair coin could come up heads a billion times in a row as well. The next flip will still be 0.5.
 The coin is the coin, but your information about the coin has changed. Probability is a fact about you, not a fact about the coin.Here is perhaps a more visceral example: On any given day, your car has a 10% chance of having blown a wheel the previous night. If it has blown a wheel, every bump will feel jarring. If it hasn't blown a wheel, any given bump will feel jarring with 10% probability. You drive over a hundred bumps, and all feel jarring. Do you think the next bump will also feel jarring?Yes, right? Because the fact that the last hundred bumps have been jarring means you probably blew a wheel last night. Even though 'previous history has no effect on future outcomes', previous history does give you information about the state of the world.Edit: Or a better example, for this community. You're on a slightly flakey wifi connection, which sometimes drops a packet at random. Any given packet is dropped with probability 1/100. Also, any given time you connect to the router, the modem is down with probability 1/10, and all of your packets will get dropped. You connect, and the first hundred packets you send are dropped. What is the probability the next packet will get dropped? Very high, because now you know that the modem is probably down. The history of the connection gives you information about the state of the connection. Similarly, the history of coin toss results gives you information about the state of the coin.(Why is this different from roulette? Because there the previous history doesn't give you information.)
 So, I think that tge question is ambiguous, and a little more direction could clear it up. If you want to know the probability, taking into account the 10 heads results thus far, I would tell the interviewee, "I am going to do this process repeatedly (picking a coin and flipping 10 times), and I'm going to keep track of what percentage do the all one side thing. What will that percentage be approximately?".
 That's not ambiguous if the applicant has taken a basic college statistics course, which is what the question is intended to determine. The term "probability" has more precise definitions in mathematics than in everyday language.
 Ah, that's the part I was missing. Thanks
 Probability is a fact about you, not a fact about the coin.Huh? It's a coin. You flip it. It has no knowledge of the past and no idea about the future. It lands and it's either heads 50% of the time and tails 50% of the time. It's all about the coin and nothing about what you've observed in the last N trials.That's the simple logic that the OP is trying to see if you understand.
 Did you miss the bit in the OP where one of the coins has heads on both sides? The coin may or may not be biased, and the results of flipping it give you information about whether or not it is biased.Explaining the bit you quoted: if you had perfect knowledge of the wind conditions, how hard the person flipped the coin, and so on, you would know precisely which side it would land on. That fact is determined. It's just because you are missing information that there's 50% probability of heads (for an unbiased coin). The probability comes out of your imperfect knowledge, and changes depending on your knowledge: for example, if you have some reason to believe the coin is biased, then you no longer think it's going to land on heads 50% of the time. Since one of the coins is biased, getting a long string of heads is reason to think that the coin they drew and are flipping is the biased coin. This information affects the probability you assign to the coin coming up heads.
 It's really interesting to watch this thread. I'm not saying that you should simply trust what the other commenters are saying, but the user crntaylor is the one that originally posted the question, and his solution is that the likelihood of the next flip being heads is 75%
 It may be a useful sanity check to simulate the experiment multiple times to see the result:`````` def choose_coin rand < 0.001 ? 1 : 0.5 end def flip_coin(coin) rand < coin ? :heads : :tails end def all_10_heads?(coin) 10.times { return false if flip_coin(coin) == :tails } true end next_flip = { :heads => 0, :tails => 0 } 1000000.times do coin = choose_coin next unless all_10_heads? coin next_flip[flip_coin(coin)] += 1 end puts next_flip[:heads].to_f / (next_flip[:heads] + next_flip[:tails])``````
 What's really interesting is that there are probabilistic programming languages where you can write a program that does a simulation just like you did, but the execution engine can compute the probabilities exactly and much faster too. It does this by computing along all possible paths in the program, and keeping track of the probability mass of each path, and then summing them all up in the end.
 Completely shameless plug for a tiny probabilistic programming language that I wrote as an embedded DSL in Haskell:https://github.com/chris-taylor/hs-probabilityThe code that solves this problem is:`````` solve = do coin <- choose (999/1000) fair biased tosses <- replicateM 10 coin condition (tosses == replicate 10 Head) nextToss <- coin return nextToss where fair = choose (1/2) Head Tail biased = certainly Head``````
 Likewise, a tire has no knowledge of the past or future. It will transfer a bump from the road to you following the laws of physics, depending on whether it is functioning properly, represented by a probability.
 I think you're incorrect because your conceptual model of what constitutes "probability" is incorrect for this type of problem.Try thinking about it in a more brute force way: imagine literally all possible outcomes of performing this experiment. In other words, create a list like this (each coin in the jar is numbered from 000 to 999 with 999 being the only biased coin, and coin flips are represented by 0 being heads and 1 being tails):`````` Picked fair coin #000, flipped 00000000000 (eleven flips) Picked fair coin #000, flipped 00000000001 Picked fair coin #000, flipped 00000000010 ... Picked fair coin #000, flipped 11111111111 .... Picked biased coin #999, flipped 11111111111 `````` Now select all of the lines above where the first ten flips are heads. Of these outcomes, how many have an eleventh flip of heads and how many have an eleventh flip of tails? Unless my idea of probability is flawed, this should be the same answer that the mathematicians in this thread are providing, so something right around 75% heads.
 Well if I can count:`````` 00000 00000 0 00000 00000 1 `````` for 999 fair coins = 1998 + 1 for fake coin = 19991000 of which has 11. flip 0So 1000/1999 ~ 50%
 True. I glossed over the crucial part, which is that you have to enumerate the same number of potential outcomes for the biased coin's ten flips as you do for each fair coin, because each coin is equally as likely to be selected from the jar. Of course, all 2^10 potential outcomes for the biased coin's ten flips are the same: all heads. So we have:`````` 00000 00000 0 00000 00000 1 `````` For 999 fair coins = 1998And 2^11 instances of 00000 00000 0 for the biased coin = 2048.That's 1998 + 2048 = 4046 equally likely outcomes that begin with ten heads. Of those, only 1998 / 2 = 999 outcomes feature an eleventh tails. So the odds of getting an eleventh heads after seeing ten heads is (4046 - 999) / 4046 =~ 0.753.
 ... because each coin is equally as likely to be selected from the jarThat's not the reason. It's because the fake coin also has two sides and therefore also 2^11 different outcomes. It just happens they all look the same.Otherwise I agree with your argument.
 True, I could have still used zeros and ones to enumerate all outcomes of the biased coin, but said that both digits represent heads.
 Where is the unfair coin in your list? Without that you just get 50% heads. This method can definitely work to get the correct answer, but you have to account for all possibilities and weigh them by their probability.
 Sorry, I edited coin #999 to be the biased coin.
 The probability of heads is`````` 0.999*0.5 + 0.001*1 = 0.5005 `````` The important thing is that as you observe heads from the coin, you learn something about the coin. As you observe more heads it is less likely to be a fair coin and more likely to be the coin with double heads. This doesn't change anything about the coin, but it changes something about what you know about the coin. See here for the correct answer: https://news.ycombinator.com/item?id=7000523
 Since the question simply asked what p(heads) was on the next flip, it seems our answers match. Thanks!
 Our answers to your question may match, but I very much doubt that our answers on the original question match. The crux is that your question is not equivalent to the original question. If you are interested in learning why that is I can explain it further, but it doesn't look like you are?
 Okay yeah, I'm stupid for pressing on while crntaylor already gave his answer. I'll shut up now.
 I think you're missing the point of the question which seems to get at whether the interviewee is familiar with/understands bayesian probability. For an excellent explanation you should see: http://yudkowsky.net/rational/bayes.
 I don't see why knowledge of Bayesian probability is necessary for this question. I don't have anything more than a passing knowledge of Bayesian probability, but I was able to produce the correct answer and a reasonable explanation using what I believe to be classical probability: https://news.ycombinator.com/item?id=7001288
 >>>Previous history has no effect on future outcomes. A fair coin could come up heads a billion times in a row as well. The next flip will still be 0.5.You hit the nail on the head here - a fair coin would. But if there are unfair coins, things start to change. If we know there's an unfair coin, and we see an unusual run, we should consider that it may be that coin.Think of this: increase the flips to 1000, and you're still getting heads each time. Would you bet on the next being heads or tails?
 More or less"The OP is only asking what the outcome of the NEXT flip is, not the probability of flipping 11 heads in a row"This is correct, however the history of flips gives us an information on the type of coin we have in our handsWould be interesting to see the probabilities if we had gotten 11 heads, 15 heads or 20 heads in a row.
 The history of coin flips has no effect on the future tosses, BUT you can use the history of flips to try to infer which coin you are dealing with.
 But that's not what the OP/Interviewer wants to know. All he asked was this:"Given that you see 10 heads, what is the probability that the next toss of that coin is also a head?"He didn't ask you to identify the coin. He just wants to know if the flip is going to be heads.
 The probability of which coin you have affects the probability of the next toss coming up heads, so having this knowledge is implicit in determining the solution.
 That probability was determined the moment you picked the coin out of the jar.It makes no difference what you do to it after the pick. Hold it in your hand for a day, flip it 10 times, sit on it, whatever - the end result is that p(heads) for that particular coin has not changed. p(heads) will be either 0.5 for a real coin or 1.0 for the rigged one.The probability then comes down to what coin you picked at the start of the trial. There's a 0.999 chance you have a real one, and 0.001 chance that you have the rigged one.
 I believe someone already presented this analogy to you, but I'm curious what your response is. Imagine the jar has only two coins, one always heads and one always tails. Choose a coin randomly, then flip it ten times. If you get ten heads, what is the probability that the next flip is heads?According to the methodology you are advocating, the probability would be 50%, because you are only considering the initial probability of selecting a coin from the jar. But using the methodology I suggested in another comment, you would list out every possible outcome and conclude that there is a 100% chance of getting another heads.
 OK, What if I flipped it 10,000,000 times and got all heads? What is the probability that I have the non-fair coin? What is the probability for the next toss?
 Another way to look at it - one coin has two heads, the other 999 have two tails. You flip the coin and get one heads. What is the possibility that the next will be heads?
 I think you are discussing different interpretations of probability (classical vs bayesian), which is causing the disconnect.
 That's not really the problem. I believe I was able to explain the correct response using classical probability: https://news.ycombinator.com/item?id=7001288. This is no more complex than asking what the odds are of being dealt a full house in poker. You can enumerate all equally likely outcomes and simply count them.
 When we pick the coin, we have 1 in 1000 chance of getting the double heads coin, and 999 in 1000 chance of getting a fair coin. Lets call this P(fair) = 0.001, and P(fake) = 0.999.When we have the double heads coin, the probability of getting 10 heads is 1: P(10 heads|fake) = 1. When we have a normal coin, the probability of getting 10 heads is P(10 heads|fair) = 0.5^10.The quantity we want to compute is`````` P(heads|10 heads) = P(fair|10 heads)*0.5 + P(fake|10 heads)*1 = P(fair|10 heads)*0.5 + (1-P(fair|10 heads)) = 1 - P(fair|10 heads)*0.5. `````` To compute P(fair|10 heads) we use Bayes' rule:`````` P(fair|10 heads) = P(10 heads|fair) * P(fair)/P(10 heads) `````` Here`````` P(10 heads) = P(10 heads|fake)*P(fake) + P(10 heads|fair)*P(fair) = 1*0.001 + 0.5^10*0.999. `````` We fill in the formula we got by Bayes' rule:`````` P(fair|10 heads) = 0.5^10 * 0.999 / (1*0.001 + 0.5^10*0.999) `````` Then we fill in the original formula:`````` P(heads|10 heads) = 1 - 0.5^10 * 0.999 / (1*0.001 + 0.5^10*0.999) * 0.5 = 0.75308947108``````
 Here's my walkthrough: http://pastebin.com/e2ea9XUD