Here are some exercises where I will be applying the Probability Theory.
I will be evaluating the event A, event B and both events
A. Based on Table 1 What is the probability of:
| B | B1 | |
| A | 10 | 20 |
| A1 | 20 | 40 |
A1. Event A (Row values)
A = 30/90 = 1/3 = 0.33 * 100 = 33.3%
A2. Event B? (Column values)
B = 30/90 = 1/3 = 0.33 * 100 = 33.3%
NOTE: 90 is the sum of all the values on the table
A3. Event A or B
I apply the general addition rule of probability:
P(A or B) = P(A) + P(B) – P(A and B)
Substituting the values:
P(A or B) = (30/90) + (30/90) – (10/90)
Now, adding the fractions:
P(A or B) = (30/90 + 30/90) – (10/90)
P(A or B) = (60/90) – (10/90)
Now, subtracting the fractions:
P(A or B) = (60 – 10) / 90
P(A or B) = 50/90
Simplifying the values:
P(A or B) = 5/9 = 0.55 * 100 = 55.5 %
A4. P(A or B) = P(A) + P(B)
P(A or B) = (30/90) + (30/90) = 0.66 *100 = 66.6 %
B. Applying Bayes’ Theorem
I was giving this scenario to determine that it will rain on the day of Janes’ wedding.
Jane is getting married tomorrow, at an outdoor ceremony in the desert. In recent years, it has rained only 5 days each year. Unfortunately, the weatherman has predicted rain for tomorrow. When it actually rains, the weatherman correctly forecasts rain 90% of the time. When it doesn’t rain, he incorrectly forecasts rain 10% of the time.
What is the probability that it will rain on the day of Jane’s wedding?
Solution: The sample space is defined by two mutually-exclusive events – it rains or it does not rain. Additionally, a third event occurs when the weatherman predicts rain. Notation for these events appears below.
Event A1. It rains on Jane’s wedding.
Event A2. It does not rain on Marie’s wedding.
Event B. The weatherman predicts rain.
In terms of probabilities, we know the following:
P( A1 ) = 5/365 = 0.0136985 [It rains 5 days out of the year.]
P( A2 ) = 360/365 = 0.9863014 [It does not rain 360 days out of the year.]
P( B | A1 ) = 0.9 [When it rains, the weatherman predicts rain 90% of the time.]
P( B | A2 ) = 0.1 [When it does not rain, the weatherman predicts rain 10% of the time.]
We want to know P( A1 | B ), the probability it will rain on the day of Marie’s wedding, given a forecast for rain by the weatherman. The answer can be determined from Bayes’ theorem, as shown below.
P( A1 | B ) = P( A1 ) P( B | A1 )/[P( A1 ) P( B | A1 ) + P( A2 ) P( B | A2 )]
P( A1 | B ) = (0.014)(0.9) / [ (0.014)(0.9) + (0.986)(0.1) ]
P( A1 | B ) = 0.111
Note the somewhat unintuitive result. Even when the weatherman predicts rain, it only rains only about 11% of the time. Despite the weatherman’s gloomy prediction, there is a good chance that Marie will not get rained on at her wedding.
B1. Is this answer True or False.
B2. Please explain why?
My answer
B1. The answer is True.
B2. This answer is true because it correctly applies Bayes’ theorem to calculate the probability that it will rain on the day of Jane’s wedding (event A1), given the weatherman’s forecast for rain (event B).
Here is why it is true:
– The prior probability of it raining on any given day (P(A1)) is relatively low, about 0.014 or 1.4%, because it only rains five days out of the year.
– The accuracy of the weatherman’s prediction when it rains (P(B | A1)) is relatively high, at 90%.
– The accuracy of the weatherman’s prediction when it does not rain (P(B | A2)) is low, at 10%.
When plugging these values into Bayes’ theorem, as it was demonstrated above, it was correctly calculated that the probability of it raining on the day of Jane’s wedding (event A1), given that the weatherman’s forecast for rain (event B) is about 11%, which is relatively low.
So, despite the weatherman’s prediction, there is still a high likelihood that it will not rain on Jane’s wedding day, which is why the answer is true.
It is an interesting example of how even when a forecast predicts rain, the actual probability of rain can be different based on historical data and the accuracy of the forecast.
C. Applying binomial distribution
(Using Textbook E-book, Introductory Statistics with R by Peter Dalgaard, pp. 65 Exercise # 3.2. )
For a disease known to have a postoperative complication frequency of 20%, a surgeon suggests a new procedure. She/he tests it on 10 patients and found there are not complications. What is the probability of operating on 10 patients successfully with the traditional method?
A hint, use dbinom function – it is part of R functions that count Density, distribution function, quantile function, and random generation for the binomial distribution with parameters size and prob.
R Answer:
> dbinom(10, size = 10, prob = 0.80)
[1] 0.1073742
>
> dbinom(0, size = 10, prob = 0.20)
[1] 0.1073742
The answer on the textbook uses X= 0, but this was unclear for me. So, I did more research, and this was the logical explanation for the first result which provided the same result as the second one:
x <- 10 # Number of successes (no complications)
size <- 10 # Total number of patients operated on
prob <- 0.80 # Probability of success (no complications). Remember that the postoperative complication frequency of 20% leaving the 80% to not have complications.