Wednesday, September 13, 2023

LIS4273 - Module 4 Assignment

 For this week's post, I will be answering the following questions.

Question 1:

Based on Table 1, what is the probability of:

B

B1

A

10

20

A1

20

40

A1: Event A

Answer: P(A) = matching outcomes / total outcomes => 30 / 90 => 1 / 3

A2: Event B

Answer: P(B) = matching outcomes / total outcomes => 30 / 90 => 1 / 3 

A3: Event A or B

Answer: 

Using the Addition Rule: P(A OR B) = P(A) + P(B) - P(A AND B)

                                                                    1/3 + 1/3 - P(A AND B)

                                                                    2/3 - P(A AND B)

Using the Independent Events Rule: P(A AND B) = P(A) * P(B)

                                                                                    1/3 * 1/3

                                                                                    1/9

P(A OR B) = 2/3 - 1/9

                   = 5/9

A4: P(A OR B) = P(A) + P(B)

Answer: The above statement is false. Under this context, 5/9 does not equal 2/3.


Question 2:

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.

Event A2: It does not rain on Jane'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?

Answer: true

B2. Please explain why?

Tracing back to the formula used to determine the probability of whether it will rain on the day of Jane’s wedding day as predicted by the weatherman, one must simply review the above calculations to see that the chance of rain is quite unlikely. The chance of rain is only 11% while there is an 89% percent chance of it not raining on Jane’s wedding day.

To break this down further, let’s look at the variables used in the Bayes' Theorem which can be expressed as follows:


While the given variables do look a bit different than the provided example, the theorem still applies. So, let’s gather up the necessary variables.

P(A) => P(A1) => 5/365 => 0.0136985

P(B|A) => P(B|A1) => 0.9

P(B) contains a few more variables than usual so let’s break this down. The formula for P(B) as provided is:

P(B) = [P(A1)P(B|A1) + P(A2)P(B|A2)]

P(B) = [(0.014)(0.9) + (0.986)(0.1)]

P(B) = 0.1109589041

Bringing it all together:

(0.0136985)(0.9) / 0.1109589041

0.01232865 / 0.1109589041

= 0.1111100556

In conclusion, we can see that indeed, there is only a 11% percent probability of it raining on Jane’s wedding day and while there is a small chance, there is greater chance of it NOT raining than raining.

Question 3:

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?

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.

You will answer the question with

dbinom(XXX, size=XXX, prob=XXX)

Answer:

dbinom(0, size = 10, prob = 0.2)

The result is 0.1073742

~ Katie Burkhart

No comments:

Post a Comment

LIS 4370 R Programming - sentimentTextAnalyzer2 Final Project

For this class's major final project, I set out to make the process of analyzing textual files and URL links for sentiment insights much...