Probability Theory

Hello again world!

This week in Advanced Statistics and Analytics we covered probability theory. We’ve been assigned three different problems to complete this week. The first is as follows:

BB1
A1020
A12040
Table 1

A. Based on Table 1, what is the probability of:
A1. Event A?
A2. Event B?
A3. Event A or B?
A4. Event A and B?

To solve this problem, I’ll be adding an additional column and row to this table, displaying the sum of all column and row values. 

 BB1P(Ai)
A102030
A1204060
P(Bi)307090
Revised Table 1

Now I’m ready to solve! 

A1. P(A) = 30/90 = .33 = 33%

A2. P(B) = 30/90 = .33 = 33%

A3. P(A or B) = 30/90 + 30/90 – 10/90 = .7 = 70%

A4. P(A and B) = (30/90) * (30/90) = .66 = 66%

The second problem is as follows:

B. Applying Bayes’ Theorem

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.

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? 

This answer is true, and can be explained using Baye’s Theorem! The probability of it raining on that particular day, given that it only rains 5 days out of the year, is 1.37%. The probability that the weatherman actually predicts rain correctly is 90%. Using Baye’s theorem, you can calculate the probability of the hypothesis (it will actually rain on Marie’s wedding) based on the probability of an event (the weatherman’s rain prediction is accurate) as P(A1 | B) = (P(A1) x P(B |A)) / (P(A1) x P(B | A)) + (P(A2) x P(B | A2)). A2 in this scenario is the “not” A. After plugging in all probabilities, as shown in the problem, we receive the answer of an 11.11% chance of rain on Marie’s wedding day. 

The third problem is as follows:

C. 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?

For this problem, I will be using the dbinom() function in R. This function takes variable x, which will be the number or successes, the size, which is the total number of trials, and prob, which is the probability of success for the trial. In our case, we want 10 successes in 10 trials with an 80% success rate. The code will look like this:

dbinom(10, size = 10, prob = .8)

When this code is run, R returns the value 1.024e-07, which translates to a .00001024% chance that the traditional method would be completed successfully on all 10 patients.

That’s all for this week’s assignment, see you next week!

Leave a comment