# Switch being red knowing that it worked? (conditional probability)

A spaceship has switches inside its cabinet control. 30% of them are red, 70% are blue. You've learned that the probability of a switch not to work is 0.12 if it is red, and 0.2 if it is blue. A switch is randomly pressed. What is the probability of it being a red switch knowing that it worked?

I'm really stuck in what to think here. Probability is not really intuitive to me. This is what I've tried, being $$R = "Red"$$, $$W = "Worked"$$:

$$P(R | W) = \frac{P(R \cap W)}{P(W)}$$, now I have to find each the numerator and denominator, but I can't get there with the info that I have.

$$\mathbb{P}[W|R]=1-0.12=0.88$$

$$\mathbb{P}[W|B]=1-0.20=0.80$$

$$\mathbb{P}[R|W]=\frac{0.30\times0.88}{0.30\times0.88+0.70\times0.80}\approx 0.32$$

this is a standard example of Bayes' Theorem

$$P(R|W)P(W)=P(W|R)P(R)\tag1$$(both sides equal $$P(R\cap W)$$)

and:$$P(W)=P(W|R)P(R)+P(W|B)P(B)\tag2$$

Here $$(2)$$ enables you to find $$P(W)$$ and after that $$(1)$$ enables you to find $$P(R|W)$$.

One tactic with these sorts of problems with two different variables (color and does/doesn't work) is to draw a square with four boxes depicting the four possibilities. For instance, you can have left = red, right = blue, top = works, bottom = doesn't work. Studies have shown the probability problems are more intuitive if they're put in terms of portions of a given total, rather than percentages, so let's take 10k buttons. 3k are read, and 7k are blue. In the lower left box, you have red buttons that don't work, which is 12% of 3k, or 360. In the upper left box, you have red buttons that work, so that's 3000-360 = 2640. The we have 1400 in the lower right box, and 5600 in the upper right box.

We're told to find the probability given that the button works, so we just have the top row. There are 2640+5600=8040 total buttons in that row, and 2640 of them are red. So we take 2640/8040 and get 32.84%.