Comments on: Is This Bathroom Occupied?
http://ask.metafilter.com/312547/Is-This-Bathroom-Occupied/
Comments on Ask MetaFilter post Is This Bathroom Occupied?Thu, 17 Aug 2017 11:02:40 -0800Thu, 17 Aug 2017 11:11:05 -0800en-ushttp://blogs.law.harvard.edu/tech/rss60Question: Is This Bathroom Occupied?
http://ask.metafilter.com/312547/Is-This-Bathroom-Occupied
The other week there was a <a href="https://fivethirtyeight.com/features/is-this-bathroom-occupied/">puzzle</a> on FiveThirtyEight about the probability of the sign on a bathroom being correct given the behavior of different people in an office (<a href="https://fivethirtyeight.com/features/can-you-plug-the-white-house-leak/">solution</a>). Can you help me figure out why <a href="https://gist.github.com/OverlappingElvis/232b2a4b5e94e3a8aa60471655c84a1f">my approach</a> doesn't work? <br /><br /> Basically, the puzzle states that you have three different types of people who change the state of a bathroom and its sign in a different way. I set up my solution as having an initial state (vacant, with sign showing vacant), and then working through a large number of randomly selected people who each change the state of the bathroom in turn. Sampling the state of the sign and the bathroom whenever a person enters or exits the bathroom, I get the following results after 100000 runs:<br>
<br>
<pre><br>
True positive probability: 0.41693<br>
True negative probability: 0.249075<br>
False positive probability: 0.250925<br>
False negative probability: 0.08307<br>
</pre><br>
<br>
As it turns out, this is totally wrong:<br>
<br>
<blockquote>There is a 62.5 percent chance that the bathroom is occupied if the sign says "Occupied." There is a 75 percent chance that the bathroom is vacant if the sign says "Vacant."</blockquote><br>
<br>
What is my solution missing, that would cause it to be so incorrect? Am I double counting some states, or failing to count others?post:ask.metafilter.com,2017:site.312547Thu, 17 Aug 2017 11:02:40 -0800OverlappingElvispuzzlemathprobabilityresolvedBy: madcaptenor
http://ask.metafilter.com/312547/Is-This-Bathroom-Occupied#4515357
Disclaimer: I can't read JavaScript without thinking, but I can do math.<br>
<br>
The problem is that you didn't make the final step of computing conditional probabilities from your results.<br>
<br>
Your "true positive" probability is the probability that the sign says occupied <i>and</i> the bathroom is actually occupied.<br>
Your "false positive" probability is the probability that the sign says occupied <i>and</i> the bathroom is actually vacant.<br>
So the probability that the bathroom is occupied, <i>conditional on</i> the sign saying occupied, is your (TP)/(TP + FP), which works out to 0.62428 or so, within a reasonable margin of error for a simulation.<br>
<br>
Similarly your TN/(TN + FN) is very close to 0.75.comment:ask.metafilter.com,2017:site.312547-4515357Thu, 17 Aug 2017 11:11:05 -0800madcaptenorBy: SaltySalticid
http://ask.metafilter.com/312547/Is-This-Bathroom-Occupied#4515360
Yeah, you're sampling wrong. You should sample at random times, then separate those by the sign marker, the compute the probabilities conditioned on that. <br>
<br>
You may have other errors too, but that's what jumped out at me.comment:ask.metafilter.com,2017:site.312547-4515360Thu, 17 Aug 2017 11:13:17 -0800SaltySalticidBy: OverlappingElvis
http://ask.metafilter.com/312547/Is-This-Bathroom-Occupied#4515366
<em>The problem is that you didn't make the final step of computing conditional probabilities from your results.</em><br>
<br>
Ok, this is totally it! Just to make sure I actually understand, we have to add the true and false positive (negative) probabilities together because we care what proportion of ALL cases where the sign says occupied actually reflects the bathroom being occupied?comment:ask.metafilter.com,2017:site.312547-4515366Thu, 17 Aug 2017 11:22:10 -0800OverlappingElvisBy: SaltySalticid
http://ask.metafilter.com/312547/Is-This-Bathroom-Occupied#4515377
What you want this: 'GIVEN that the sign says occupied, what is the probability that it is in fact occupied?'<br>
<br>
Maybe that's what you meant, with "what proportion of ALL cases... " but your wording is less clear, and at first I thought you were referring to the same thing as the "true positive" case at the top. It's a good habit to stick to the formulaic language for this stuff, the semi-standardized nature makes it clearer. <br>
<br>
Anyway the conditional probability can be computed by the formula above in this case, which is essentially the same as the first formula given on Wikipedia's page on <a href="https://en.wikipedia.org/wiki/Conditional_probability">conditional probability</a>.comment:ask.metafilter.com,2017:site.312547-4515377Thu, 17 Aug 2017 11:46:29 -0800SaltySalticidBy: OverlappingElvis
http://ask.metafilter.com/312547/Is-This-Bathroom-Occupied#4515380
Thanks, I didn't know that conditional probability was what I was looking for! I'm just a programmer without a strong math background.comment:ask.metafilter.com,2017:site.312547-4515380Thu, 17 Aug 2017 11:52:04 -0800OverlappingElvisBy: OverlappingElvis
http://ask.metafilter.com/312547/Is-This-Bathroom-Occupied#4515428
Just to close the loop, I've updated the <a href="https://gist.github.com/OverlappingElvis/232b2a4b5e94e3a8aa60471655c84a1f">gist</a> of my solution and with that missing piece I now get the results I was looking for (and more importantly I understand why)!<br>
<br>
<pre>Results after 500000 runs:<br>
Probability of the bathroom being occupied when the sign reads occupied: 0.6251<br>
Probability of the bathroom being vacant when the sign reads vacant: 0.7506</pre>comment:ask.metafilter.com,2017:site.312547-4515428Thu, 17 Aug 2017 13:29:32 -0800OverlappingElvis