|
| 1 | +\documentclass[11pt]{article} |
| 2 | + |
| 3 | +\usepackage[utf8]{inputenc} |
| 4 | +\usepackage[a4paper]{geometry} |
| 5 | + |
| 6 | + |
| 7 | +\usepackage{graphicx} |
| 8 | +\usepackage{amsmath,amssymb,mleftright} |
| 9 | +\usepackage{mathtools} % For cases environment |
| 10 | +\usepackage[round]{natbib} |
| 11 | +\usepackage{microtype} |
| 12 | +\usepackage{xcolor} |
| 13 | + |
| 14 | +\usepackage[british]{babel} |
| 15 | + |
| 16 | +% Make a title for your question and provide your name (or a pseudonymn) |
| 17 | +\title{Bayes and 1000 coins} |
| 18 | +\author{D. Bester} |
| 19 | +\date{} |
| 20 | + |
| 21 | +\begin{document} |
| 22 | +\maketitle |
| 23 | + |
| 24 | +\section{Question} |
| 25 | + |
| 26 | +You have a bag with 1000 coins in it. |
| 27 | +One of them is a double headed coin, the other 999 are fair coins. |
| 28 | +I pick one coin from the bag at random, and flip it ten times. |
| 29 | +It comes up heads all ten times. |
| 30 | +What is the probability that I have selected the double headed coin? |
| 31 | + |
| 32 | +\section{Answer} |
| 33 | +This is another question about Bayes' law. |
| 34 | +Let's make some notation to use, define |
| 35 | +$H$ as the event that a coin comes up head, and $T$ that a coin comes up tails, and let $10H$ denote getting ten heads from ten coin flips. |
| 36 | +Let $C_{F}$ be the event where we select the fair coin from the bag, and $C_{R}$ the event that we select the rigged coin. |
| 37 | +This is one of the simplest questions about Bayes' law as there is not much to unpack. |
| 38 | +You want to know the probability of the rigged coin being selected, given you saw ten heads. |
| 39 | +By rote application of Bayes' law: |
| 40 | +\begin{align} |
| 41 | +\label{eq:1000coins:bayeslaw1} |
| 42 | + P( C_{R} \vert 10H) |
| 43 | + &= |
| 44 | + \frac{ |
| 45 | + P( 10H \vert C_{R} ) |
| 46 | + P( C_{R} ) |
| 47 | + }{ |
| 48 | + P( 10H \vert C_{R} ) |
| 49 | + P( C_{R} ) |
| 50 | + + |
| 51 | + P( 10H \vert C_{F} ) |
| 52 | + P( C_{F} ) |
| 53 | + } |
| 54 | + \text{.} |
| 55 | +\end{align} |
| 56 | +Consider |
| 57 | +$P( 10H \vert C_{R} )$, the probability of getting ten heads in a row with the rigged coin. |
| 58 | +Since this will happen with certainty |
| 59 | +$P( 10H \vert C_{R} ) = 1$. |
| 60 | +For the fair coin each flip is independent, so you have |
| 61 | +$P( 10H \vert C_{F} )=P( 10 \vert C_{F} )^{10}= ({1}/{2})^{10} = {1}/{1024}$. |
| 62 | +Since you picked te coin out of a bag of 1000 coins, the probability that you selected the rigged coin is |
| 63 | +$P(C_{R}) = 1/1000$ and the probability that the coin you selected is fair is |
| 64 | +$P(C_{F}) = 999/1000$. |
| 65 | +You can substitute |
| 66 | +\begin{align*} |
| 67 | + P( C_{R} \vert 10H) |
| 68 | + &= |
| 69 | + \frac{ |
| 70 | + (1) |
| 71 | + \left( \frac{1}{1000} \right) |
| 72 | + }{ |
| 73 | + (1) |
| 74 | + \left( \frac{1}{1000} \right) |
| 75 | + + |
| 76 | + \left(\frac{1}{1024}\right) |
| 77 | + \left(\frac{999}{1000}\right) |
| 78 | + } |
| 79 | + \\ |
| 80 | + &= |
| 81 | + \frac{ |
| 82 | + 1 |
| 83 | + }{ |
| 84 | + 1 |
| 85 | + + |
| 86 | + \left(\frac{999}{1024}\right) |
| 87 | + } |
| 88 | + \\ |
| 89 | + &= |
| 90 | + \frac{ |
| 91 | + 1 |
| 92 | + }{ |
| 93 | + \left(\frac{2023}{1024}\right) |
| 94 | + } |
| 95 | + \\ |
| 96 | + &= |
| 97 | + \frac{1024}{2023} |
| 98 | + \text{,} |
| 99 | +\end{align*} |
| 100 | +which is slightly more than $1/2$. |
| 101 | + |
| 102 | +This question is so well known that your interviewer likely won't even let you finish it. |
| 103 | +Once they see you can answer it they will move on to the next question. |
| 104 | +My interviewer didn't care about the answer, but he wanted me to describe \eqref{eq:1000coins:bayeslaw1} in detail. |
| 105 | +Since Bayes' law is just the application of conditional probability, you can derive it from first principles: |
| 106 | +\begin{align} |
| 107 | +\label{eq:1000coins:bayesexplain} |
| 108 | + P( C_{R} \vert 10H) |
| 109 | + &= |
| 110 | + \frac{ |
| 111 | + P( 10H , C_{R} ) |
| 112 | + }{ |
| 113 | + P( 10H ) |
| 114 | + } |
| 115 | +\end{align} |
| 116 | +and even a frequentist will agree with you here. |
| 117 | +The nominator is the joint probability of ten heads and the rigged coin, and it is easier to split this into another conditional probability: |
| 118 | +\begin{align*} |
| 119 | + P( 10H , C_{R} ) |
| 120 | + = |
| 121 | + P( 10H \vert C_{R} ) p( C_{R} ) |
| 122 | + \text{.} |
| 123 | +\end{align*} |
| 124 | +Technically, we can also say |
| 125 | +\begin{align*} |
| 126 | + P( 10H , C_{R} ) |
| 127 | + = |
| 128 | + P( C_{R} \vert 10H ) p( 10H ) |
| 129 | + \text{,} |
| 130 | +\end{align*} |
| 131 | +but since this contains the probability we are trying to solve, so this line of thinking will lead to circular reasoning and is not helpful. |
| 132 | + |
| 133 | +You can expand denominator in |
| 134 | +\eqref{eq:1000coins:bayesexplain} |
| 135 | +using the law of total probability and considering all the possible ways you can see ten heads. |
| 136 | +Since you only have two types of coins---either a fair coin or a rigged one---there are only two ways ten heads can happen: |
| 137 | +\begin{align*} |
| 138 | + P( 10H ) = |
| 139 | + P( 10H \vert C_{R} )p(C_{R}) |
| 140 | + + |
| 141 | + P( 10H \vert C_{F} )p(C_{F}) |
| 142 | + \text{.} |
| 143 | +\end{align*} |
| 144 | +If the interviewer wants you to explain even further, you can note that this is derived form the marginal probability |
| 145 | +\begin{align*} |
| 146 | + P( 10H ) = |
| 147 | + P( 10H , C_{R} ) |
| 148 | + + |
| 149 | + P( 10H , C_{F} ) |
| 150 | + \text{,} |
| 151 | +\end{align*} |
| 152 | +by applying the law of conditional probability to each of the terms. |
| 153 | +Combining the nominator and the denominator yields \eqref{eq:1000coins:bayeslaw1}. |
| 154 | +You could also opt for a visual explanation of Bayes' Law, such as the one in question \textcolor{red} {TODO: ref question}. |
| 155 | + |
| 156 | +This question uses Bayes' law as a starting to point to test your handle on important probability concepts and your ability to grapple with notation on-the-spot. |
| 157 | +It is easy to confuse the basic concepts or to forget some useful rules, which is another reason for doing proper interview preparation, no matter how smart you think you are. |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | +%% Uncomment this if you need references |
| 164 | +%\bibliography{references.bib} |
| 165 | +%\bibliographystyle{chicago} |
| 166 | + |
| 167 | + |
| 168 | +\end{document} |
0 commit comments