---
title: "Homework 2 Help: Conditional Probability Example"
author: "Tom Fletcher"
date: "September 7, 2017"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, comments = "")
```
When dealing with conditional probability, there are several questions you could answer with the same starting information. The starting point is always to draw the __conditional probability tree__ for the problem. Following that, you may be asked a question that involves __total probability, Bayes' rule, or independence.__ We will go through all of these possibilities in the following example.
# Problem Setup
_You have a system with a main power supply and auxillary power supply. The main power supply has a 10\% chance of failure. If the main power supply is running, the auxillary power supply also has a 10\% chance of failure. But if the main supply fails, the auxillary supply is more likely to be overloaded and has a 15\% chance to fail._
# 1. Draw a Conditional Probability Tree
You can draw a conditional probability tree in your favorite drawing software, or you can format the information into a table. First, be sure to define the notation you will use for events:
- $M$ = "main power is working"
- $M^c$ = "main power fails"
- $A$ = "auxillary power is working"
- $A^c$ = "auxillary power fails"
Now we can format the conditional probability tree as a table:
First Events | Second Events | Joint Probabilities |
-----------------|--------------------------|---------------------------|
$P(M) = 0.9$ | $P(A \mid M) = 0.9$ | $P(A \cap M) = 0.81$ |
| $P(A^c \mid M) = 0.1$ | $P(A^c \cap M) = 0.09$ |
$P(M^c) = 0.1$ | $P(A \mid M^c) = 0.85$ | $P(A \cap M^c) = 0.085$ |
| $P(A^c \mid M^c) = 0.15$ | $P(A^c \cap M^c) = 0.015$ |
Note above that you need to put an explicit line break `
` in a cell that you want to be blank.
# 2. Total Probability Question
_What is the probability of the auxillary power failing?_
### Solution
Here we just add all of the joint probabilities involving the event $A^c$.
$$P(A^c) = P(A^c \cap M) + P(A^c \cap M^c) = 0.09 + 0.015 = 0.105$$
# 3. Bayes' Rule Question
_If the auxillary power is working properly, what is the probability that the main power fails?_
### Solution
First, using the Complement Rule, we compute
$$P(A) = 1 - P(A^c) = 1 - 0.105 = 0.895$$
Now we can just plug the information we have into the formula for Bayes' Rule:
$$
\begin{align}
P(M^c \mid A) &= \frac{P(A \mid M^c) P(M^c)}{P(A)} & \text{Bayes' Rule}\\
&= \frac{0.85 \times 0.1}{0.895} & \text{Plugging in numbers}\\
&= `r 0.85 * 0.1 / 0.895` & \text{Answer!}\\
\end{align}
$$
Notice in the last line we used an inline R command to do the final calculation for us. (Be lazy, don't do your own arithmetic!)
# 4. Independence Question
_Is the auxillary power failing independent of the main power failing?_
There are many equivalent formulas you can check for independence. (See the lecture notes.) We will first try this one:
$$P(A^c | M^c) \stackrel{?}{=} P(A^c).$$
The left-hand side of this is from the tree, and the right-hand side is from the answer to the total probability question above. We have
$$P(A^c | M^c) = 0.15 \neq 0.105 = P(A^c).$$
This means that $A^c$ and $M^c$ are __not__ independent (in other words, they are dependent).