suppressWarnings(
  library(tinytex)
)

Q1

\[ \begin{align} P(Positive \lvert Disease) &= 0.96 \: \rightarrow \: Sensitivity \\ P(Negative \lvert No \: Disease) &= 0.98 \: \rightarrow \: Specificity \\ P(Diseased) &= 0.001 \: \rightarrow \: Prevalence \end{align} \]

1a

\[ P(Disease \lvert Positive) = \frac{P(Positive \lvert Disease)P(Diseased)}{P(Positive \lvert Disease)P(Diseased) + P(Positive \lvert No \: Disease)P(Positive)} \]

Note: \[ \begin{aligned} P(Positive \lvert No \: Disease) &= 1 - Specificity = 1 - 0.98 = 0.02 \\ P(No \: Disease) &= 1 - P(Negative) = 1 - 0.001 = 0.999 \end{aligned} \]

Thus: \[ \begin{aligned} P(Disease \lvert Positive) &= \frac{0.96 * 0.001}{0.96 * 0.001 + 0.02 * 0.999} \\ &\approx 0.0458 \end{aligned} \]

1b

\[ \begin{aligned} \text{Number of Positive Patients } = 0.0458 * 100,000 \text{Median Cost } &= \$100,000 \\ \text{Administration Cost } &= \$1000 \\ \text{Total Patients } &= 100,000 \\ \\ \text{Total Median Cost } &= \$100,000 * \text{Number of Positive Patients} \\ &= \$100,000 * 4,580 \\ &= \$458,000,000 \\ \text{Total Adminsitration Cost } &= \$1000 * 100,000\\ &= \$100,000,000 \\ \text{Total Cost } &= \text{Total Median Cost } + \text{Total Adminsitration Cost } \\ &= \$558,000,000 \end{aligned} \]

Q2

\[ \begin{aligned} N &= 24 \\ p &= 0.05 \end{aligned} \]

N <- 24
p <- 0.05

2a

\(P(n = 2)\)

P_equal_2 <- dbinom(2, N, p)
print(P_equal_2)
## [1] 0.2232381

2b

\(P(n \geq 2)\)

P_geq_2 <- pbinom(1, N, p, lower.tail = FALSE)
print(P_geq_2)
## [1] 0.3391827

2c

\(P(n < 2)\)

P_lt_2 <- pbinom(1, N, p, lower.tail = TRUE)
print(P_lt_2)
## [1] 0.6608173

2d

$ $

EV <- N * p
print(EV)
## [1] 1.2

2e

$

variance <- N * p * (1 - p)
std <- sqrt(variance)
print(std)
## [1] 1.067708

Q3

\[ \begin{aligned} \lambda &= 10 \\ \end{aligned} \]

lambda <- 10

3a

\(p(x = 3)\)

P_eq_3 <- dpois(3, lambda)
print(P_eq_3)
## [1] 0.007566655

3b

\(p(x > 10)\)

p_gt_10 <- ppois(10, 10, lower.tail = FALSE)
print(p_gt_10)
## [1] 0.4169602

3c

\(\text{Expected Value}\)

EV_8 <- 8 * lambda
print(EV_8)
## [1] 80

3d

\(\text{Standard Deviation Poison}\)

variance_poison <- lambda
std_poison <- sqrt(variance_poison)
print(std_poison)
## [1] 3.162278

3e

\(\text{Percent Utilization}\)

percent_utilization <- (EV_8/(24*3)) * 100
print(percent_utilization)
## [1] 111.1111

The percent utilization is 111.11%. This means that the hospital is using more resources than they have. I would recommend the family open another clinic.

Q4

4a

\[ \begin{aligned} P(X = x) &= \frac{\left(\begin{array}{c}a\\ x\end{array}\right)\left(\begin{array}{c}N - a\\ n - x\end{array}\right)}{\left(\begin{array}{c}N\\ n\end{array}\right)} \\ N &= 30 \\ n &= 6 \\ a &= 15 \\ x &= 5 \end{aligned} \]

Using the formula

P_x_eq_3 <- (choose(15, 5) * choose(15, 1))/(choose(30, 6))
print(P_x_eq_3)
## [1] 0.07586207

Using R

P_x_eq_3 <- dhyper(5, 15, 15, 6)
print(P_x_eq_3)
## [1] 0.07586207

4b

Expected value of success (nurses) \[ E(X) = n *\frac{a}{N} \]

E_x <- 6 * 15/30
print(E_x)
## [1] 3

4b

Expected value of failures (non nurses) \[ E(\grave{x}) = n - E(x) \]

E_x_hat <- 6 - E_x
print(E_x_hat)
## [1] 3

Q5

\[ \begin{aligned} P(X = x) &= 1 - (1 - p)^{x} \\ p &= 0.001 \end{aligned} \]

p_geom <- 0.001

5a

\(P(X = 1200)\) Using the formula

x = 1200
P_x <- 1 - (1 - p_geom)^(x)
cat('Probability of getting a serious injury after driving 1200hrs: ', P_x)
## Probability of getting a serious injury after driving 1200hrs:  0.6989866
p_1200 <- pgeom(1200, p_geom)
cat('Probability of getting a serious injury after driving 1200hrs: ', p_1200)
## Probability of getting a serious injury after driving 1200hrs:  0.6992876

5b

\(P(X = 15000)\) #Hours driven in 15months assuming drivers keep the same pace of 1200hrs in 12months Using the formula

x = 1500
P_x <- 1 - (1 - p_geom)^(x)
cat('Probability of getting a serious injury after driving 1500hrs: ', P_x)
## Probability of getting a serious injury after driving 1500hrs:  0.7770372
p_1500 <- pgeom(1500, p_geom)
cat('Probability of getting a serious injury after driving 1500hrs: ', p_1500)
## Probability of getting a serious injury after driving 1500hrs:  0.7772602

5c

Expected number of hours before a driver is injured \[ E(x) = \frac{1}{p} \]

E_x_geom <- 1/p_geom
cat('Expected number of hours before serious injury: ', E_x_geom)
## Expected number of hours before serious injury:  1000

5d

\(P(X)\) for 100hrs after driving for 1200hrs is \(P(X = 100)\). The probability of the first event does not affect the probability of the next event Using formula

x = 100
P_x <- 1 - (1 - p_geom)^(x)
cat('Probability of getting into an accident 100hrs after driving 1200hrs: ', P_x)
## Probability of getting into an accident 100hrs after driving 1200hrs:  0.09520785
x = 100
P_100 <- pgeom(x, p_geom)
cat('Probability of getting into an accident 100hrs after driving 1200hrs: ', P_100)
## Probability of getting into an accident 100hrs after driving 1200hrs:  0.09611265

6

Because we are trying to predict the number of events that occur in a given time frame we will use Poison Distribution where \(\lambda = 1\)

lambda = 1

6a

p_gt_2 <- ppois(2, 1, lower.tail = FALSE)
cat('The probability of having more than two failures in 1000hrs is: ', p_gt_2)
## The probability of having more than two failures in 1000hrs is:  0.0803014

6b

Expected failure

E_x_1000hrs = 1000 * lambda
cat('The expected number of failures in 1000hrs is: ', E_x_1000hrs)
## The expected number of failures in 1000hrs is:  1000

Q7

Uniform Distribution

# Probability of waiting more than 10 minutes
p_gt_10 <- (30 - 10)/30
cat('The probability of waiting for more than 10 minutes is: ', p_gt_10, '\n')
## The probability of waiting for more than 10 minutes is:  0.6666667
# Probability of waiting for at least 5 minutes after waiting 10 minutes
p_atl_5 <- (30 - 15)/(30 - 10) #15min because the patient has already waited 10min
cat('Probability of waiting for at least 5 more minutes is: ', p_atl_5, '\n')
## Probability of waiting for at least 5 more minutes is:  0.75
# Expected wait time
E_x <- (0 + 30)/2 # midpoint of uniform distribution
cat('The expected wait time is: ', E_x)
## The expected wait time is:  15

Q8

Exponential Distribution failure rate, \(\lambda = \frac{1}{10}\)

rate <- 1/10

# Expected failure time (10 years)
E_x <- 1/rate
cat('The expected failure time in years is: ', E_x, '\n')
## The expected failure time in years is:  10
# Standard deviation
variance <- (1/rate)^2
std <- sqrt(variance)
cat('The standard deviation in years is: ', std, '\n')
## The standard deviation in years is:  10
# probability that the MRI will fail after 8yrs
p_8 <- pexp(8, rate, lower.tail = FALSE)
cat('The probability that the MRI will fail after 8 years: ', p_8, '\n')
## The probability that the MRI will fail after 8 years:  0.449329
# probability that the MRI will fail 2 yrs after the first 8 yrs
p_2_after_8 <- pexp(10, rate) - pexp(8, rate)
cat('Probability that the MRI will fail 2 yrs after the first 8 yrs: ', p_2_after_8)
## Probability that the MRI will fail 2 yrs after the first 8 yrs:  0.08144952