31

Out of curiosity, here's a question from Glassdoor (Facebook Data Science Interview)

You're about to get on a plane to Seattle. You want to know if you should bring an umbrella. You call 3 random friends of yours who live there and ask each independently if it's raining. Each of your friends has a 2/3 chance of telling you the truth and a 1/3 chance of messing with you by lying. All 3 friends tell you that "Yes" it is raining. What is the probability that it's actually raining in Seattle?

Using Bayesian analysis, it's pretty clear that you cannot solve this without the prior probability of raining in Seattle.

However, here's a different approach which I found interesting in the discussion contained in Glassdoor.

Since all three friends said "Yes", the question basically boils down to what is the probability that all three friends are telling the truth given that all three friends said "Yes". Since you ask all three friends independently, the probability that all three friends are telling the truth is given by (2/3)(2/3)(2/3) = 8/27. Thus, the probability of it raining is 8/27.

While this is perhaps a bit compelling, I'm not sure if it's correct. Anyone have any ideas?

Thanks!

R.P.
  • 1,405
Vincent
  • 455
  • 6
    An estimate for the prior probabillity of rain can be found by simply googling 'number of rainy days in seattle' which shows that approx. 150 days of the year has rain so a reasonable number to use is $p_{\rm rain} \approx 0.4$. – Winther Oct 27 '15 at 02:01
  • The question is incomplete:) – Pole_Star Apr 18 '21 at 14:33

8 Answers8

26

To put it a bit more formally... Let $p_r$ be the prior probability for rain ($p_n\equiv 1-p_r$). Then the probability of rain given 3 "yes" replies $\{y,y,y\}$ is

$$ \mathsf{P}(\text{rain}\mid \{y,y,y\})=\frac{\mathsf{P}(\text{rain}\cap\{y,y,y\})}{\mathsf{P}(\{y,y,y\})} \\ =\frac{\mathsf{P}(\{y,y,y\}\mid\text{rain})\cdot p_r}{\mathsf{P}(\{y,y,y\}\mid\text{rain})\cdot p_r+\mathsf{P}(\{y,y,y\}\mid\text{no rain})\cdot p_n} $$

Next, if we assume conditional independence of friends' replies, the last formula becomes

$$ =\frac{(2/3)^3\cdot p_r}{(2/3)^3\cdot p_r+(1/3)^3\cdot p_n}=\frac{p_r}{p_r+ p_n/8}. $$

14

Each of the above analyses fail to assess the logic of the question primarily in their approach. Since all three say it is raining, you cannot approach the solution by determining each friend's propensity for truth. For it not to be raining, they ALL must be lying. Therefore, the solution must be the inverse of the probability that all three are "messing with you." (1/3)x(1/3)x(1/3)=1/27 (3.7% chance they are all lying). Since there is only a 3.7% chance all three friends are messing with you, there is a 96.3% chance it is raining.

  • 1
    This is the correct approach. Taking a Bayesian approach is probably appropriate in a real world sense, but if you are told by the interviewer you have no ability to determine the priors, you can't use Bayesian.

    Additional signal should only improve your fidelity, so you don't need all friends to be correct. You can arrive at the same answer more clumsily by calculating the probability at least one friend is correct. P(A or B or C) = P(P(A or B) or C) = (2/3 + 2/3 - (2/3)*(2/3)) + 2/3 - (2/3 + 2/3 - (2/3)*(2/3))*(2/3) = 96.3

    – Brendan Mar 23 '20 at 21:24
7

Your arithmetic is wrong, but that's not the worst problem with your method.

Would you apply the same logic if the question was "are there two blue moons in the sky"?

7

** Edited **

Assuming prior possibility of raining on any day is 0.25, P(raining given all three say yes) can be calculated using Bayes theorem

i.e. P(R|YYY) = P(R)*P(YYY|R)/P(YYY)

P(YYY) = all tell truth when raining + all lie when not raining = 0.25 * (2/3)^3 + 0.75 * (1/3)^3

P(R|YYY) = 0.25 * (2/3)^3 / (0.25 * (2/3)^3 + 0.75 * (1/3)^3) = 8 / (8 + 3) = 8/11

2

You are completely right about Bayesian analysis. It is indeed correct to say that the probability is 8/27 (not 8/9) that they all tell the truth, prior to the experiment. However, post the experiment, you have three answers. If in the area it is unlikely to rain (for interest in the desert), the three 'yes' answers are proof to two things: a) it might indeed be raining b) they are lying.

So, after the experiment, the probability is not 8/27 that are telling the truth, because the answers they give are proof of their honesty.

There is some calculations tricks not many people know. The 2/3 you can see as a prior probability change of 1/2 going to 2/3, even if the prior probability is not 1/2. Now, if you take the "Odd", which is $p / (1-p)$, then you can just simply multiply them. $Odd(2/3) = 2$. If your prior probability is $1/10$, then the $Odd(1/10) = 1/9$. For three time yes, you multiply it with 2 for three times. You get 8/9. Back to normal probability, you get $8/17$.

Lucas K.
  • 121
  • 4
2

d.k.o. provided a detailed answer for how to do the Bayesian analysis. I'll try and give an intuition for the second part of your question:

Since all three friends said "Yes", the question basically boils down to what is the probability that all three friends are telling the truth given that all three friends said "Yes". Since you ask all three friends independently, the probability that all three friends are telling the truth is given by (2/3)(2/3)(2/3) = 8/27. Thus, the probability of it raining is 8/27.

While this is perhaps a bit compelling, I'm not sure if it's correct. Anyone have any ideas?

This approach is incorrect, precisely because it fails to take into account the a priori probability of rain in Seattle. To see that the probability of rain in Seattle is important, just reframe the question a bit: - What if this question was posed about an imaginary location in which it never rains? - Or what if it was about a location in which it always rains? The approach you describe above obviously fails in both these cases: in the former case, your friends must be lying, and in the latter, they must be telling the truth.

Bayesian analysis works in these "edge cases": in d.k.o.'s notation, if $p_r = 1$, then $\mathsf{P}(\text{rain}\mid \{y,y,y\}) =1$, and similarly, if $p_r = 0$, then $\mathsf{P}(\text{rain}\mid \{y,y,y\}) =0$.

(I suspect Robert Israel was trying to make a similar point about what happens if the prior probability of the event your friends are reporting on is $0$.)

Chai
  • 56
1

No matter it is raining or no, the possibility of $3$ friends take same action is $111$ and $000$ out of $6$ permutations that is always gonna be $1/3.$
Or you can do $(2/3)^3 + (1/3)^3 = 1/3\;$ which makes more sense to the question, since they either all lie or all be honest. So the base possibility of the problem is $\;1/3.\;$ The probability of it rains and $3$ friends speaking the truth is $(2/3)^3 = 8/27.\;$ Therefore $p$ of raining is $(8/27) / (1/3) = 8/9$

Tony
  • 11
0

Here's my 2 cents to this problem:

It's either all 3 are speaking the truth, or all of them are lying. Which makes it chances of 2/3 and 1/3 respectively.

So, the probability of raining is either Event: Rain and Truth, or Event: No Rain and Lie.

Let's assume the prior chances of rain in Seattle is 25%.

In that case, P(Rain | Y Y Y) = (0.25 * 2/3) / (0.25 * 2/3) + (0.75 * 1/3) = 0.4

So, the chance of actually raining in Seattle would be 40%

Sinha
  • 1