1. (Bayesian). A new test for multinucleoside-resistant (MNR) human immunodeficiency virus type 1 (HIV-1) variants was recently developed. The test maintains 96% sensitivity, meaning that, for those with the disease, it will correctly report “positive” for 96% of them. The test is also 98% specific, meaning that, for those without the disease, 98% will be correctly reported as “negative.” MNR HIV-1 is considered to be rare (albeit emerging), with about a .1% or .001 prevalence rate. Given the prevalence rate, sensitivity, and specificity estimates, what is the probability that an individual who is reported as positive by the new test actually has the disease? If the median cost (consider this the best point estimate) is about $100,000 per positive case total and the test itself costs $1000 per administration, what is the total first-year cost for treating 100,000 individuals?

\[P(True Positive Result)=\frac{P(Positive) * P(Positive Rate)}{P(Positive)*P(Positive Rate)+P(False Positive)∗P(Negative Rate)} \]

numerator <- .001 *.96
denominator <- .001 *.96 + .02 * (1-.001)
numerator/denominator
## [1] 0.04584527
test_cost <- 1000
pos_cost <- 100000
sample_pop <- 100000
true_pos <-.001

sprintf('The total first year cost for treating 100,000 individuals is %f',test_cost * sample_pop + sample_pop * true_pos * pos_cost)
## [1] "The total first year cost for treating 100,000 individuals is 110000000.000000"
  1. The probability of your organization receiving a Joint Commission inspection in any given month is .05. What is the probability that, after 24 months, you received exactly 2 inspections? What is the probability that, after 24 months, you received 2 or more inspections? What is the probability that your received fewer than 2 inspections? What is the expected number of inspections you should have received? What is the standard deviation? \[\binom{n}{k}p^kq^{n-k}\]
exact_two <- (factorial(24)/(factorial(2)*(factorial(24-2)))) * .05**2 * 0.95**(24-2)
print(exact_two)
## [1] 0.2232381
zero_inspection <- (factorial(24)/(factorial(0)*(factorial(24-0)))) * .05**0 * 0.95**(24-0)
one_inspection <- (factorial(24)/(factorial(1)*(factorial(24-1)))) * .05**1 * 0.95**(24-1)
1-(zero_inspection+one_inspection)
## [1] 0.3391827
zero_inspection+one_inspection
## [1] 0.6608173
#Expected
.05 * 24
## [1] 1.2
#Standard Deviation
sqrt((24*0.05)*(1-0.05))
## [1] 1.067708
  1. (Poisson). You are modeling the family practice clinic and notice that patients arrive at a rate of 10 per hour. What is the probability that exactly 3 arrive in one hour? What is the probability that more than 10 arrive in one hour? How many would you expect to arrive in 8 hours? What is the standard deviation of the appropriate probability distribution? If there are three family practice providers that can see 24 templated patients each day, what is the percent utilization and what are your recommendations?
#$\lambda $
lambda <- 10
p_poisson <- 3

print((lambda**p_poisson * exp(-lambda))/factorial(p_poisson))
## [1] 0.007566655
dpois(3,10)
## [1] 0.007566655
vals <- seq(0,10)
manual_poisson<-function(p_x) {
    return ((10**p_x * exp(-10))/factorial(p_x))
}

# Complement to calculate probability of greater than 10 arriving
print(1- sum(unlist(lapply(vals,manual_poisson))))
## [1] 0.4169602
#Expected amount of patients in 8 hours
10*8
## [1] 80
#Standard Deviation of Poisson Distribution
print(sqrt(10))
## [1] 3.162278

Well considering that the mean rate previously observed is per hour we need to convert the 24 patients per day to determine how many patients each hour. It is not entirely clear if the patient load is per practice or in total

  1. If the number provided is split up per practice then there are 8 patients per day and one arriving per hour assuming 8 hours in one day. This rate seems quite unlikely given the baseline of 10 arrivals per hour and I would recommend either discussing with other practices how they handle higher patient load or consider adding additional staff to accommodate demand.
  2. If each practice out of the three can handle 24 patients per day then in an 8 hour day there are 3 patients arriving each hour which still appears very unlikely per the poisson distibution. Perhaps alternative methods can be adapted to handle additional patient load or discussing other providers best practices would be helpful.
  1. (Hypergeometric). Your subordinate with 30 supervisors was recently accused of favoring nurses. 15 of the subordinate’s workers are nurses and 15 are other than nurses. As evidence of malfeasance, the accuser stated that there were 6 company-paid trips to Disney World for which everyone was eligible. The supervisor sent 5 nurses and 1 non-nurse. If your subordinate acted innocently, what was the probability he/she would have selected five nurses for the trips? How many nurses would we have expected your subordinate to send? How many non-nurses would we have expected your subordinate to send?

\(\frac{\binom{15}{1}\binom{15}{5}}{\binom{30}{6}}\)

nurses_n <- 15
non_nurses_n <-15
selected <- 6
nurses_s <- 5
non_nurses_s <- 1

hyper_s <- (ncol(combn(non_nurses_n,non_nurses_s))*ncol(combn(nurses_n,nurses_s)))/ncol(combn(nurses_n+non_nurses_n,selected))

print(hyper_s)  
## [1] 0.07586207
hyper_s == dhyper(x=non_nurses_s,m=non_nurses_n,n=nurses_n,k=selected)
## [1] FALSE
sprintf("The probability of selecting five nurses for the trips is: %f", hyper_s)
## [1] "The probability of selecting five nurses for the trips is: 0.075862"
# 3 expected nurses
6*(15/30)
## [1] 3
# 3 non-nurses
6*(15/30)
## [1] 3
  1. (Geometric). The probability of being seriously injured in a car crash in an unspecified location is about .1% per hour. A driver is required to traverse this area for 1200 hours in the course of a year. What is the probability that the driver will be seriously injured during the course of the year? In the course of 15 months? What is the expected number of hours that a driver will drive before being seriously injured? Given that a driver has driven 1200 hours, what is the probability that he or she will be injured in the next 100 hours?

\(P(X=x) =q^{x-1}p\) \(CDF = 1-(1-p)^x\)

x_1 <- 1200
geo_p <- 0.001
#What is the probability that the driver will be seriously injured to traverse this area for 1200 hours in the course of a year?
1-(1-geo_p)^x_1
## [1] 0.6989866
# In the course of 15 months?
1-(1-geo_p)^(x_1*15/12)
## [1] 0.7770372
#Expected Value of Hours
1/geo_p
## [1] 1000
#Given that a driver has driven 1200 hours, what is the probability that he or she will be injured in the next 100 hours?
1-(1-geo_p)^(x_1+100)-(1-(1-geo_p)^x_1)
## [1] 0.02865884
  1. You are working in a hospital that is running off of a primary generator which fails about once in 1000 hours. What is the probability that the generator will fail more than twice in 1000 hours? What is the expected value?
gen_lambda <- 1

gen_fails <- seq(0,1,2)
manual_poisson_gen<-function(p_x) {
    return ((1**p_x * exp(-1))/factorial(p_x))
}

# Complement to calculate probability of greater than 2 fails
print(1- sum(unlist(lapply(gen_fails,manual_poisson_gen))))
## [1] 0.6321206

Expected Value Lambda in this case is 1

  1. A surgical patient arrives for surgery precisely at a given time. Based on previous analysis (or a lack of knowledge assumption), you know that the waiting time is uniformly distributed from 0 to 30 minutes. What is the probability that this patient will wait more than 10 minutes? If the patient has already waited 10 minutes, what is the probability that he/she will wait at least another 5 minutes prior to being seen? What is the expected waiting time?
# Given 20 out of the total 30 minute internval is uniformly distributed then it should represent 2/3
(30-10)/(30-0)
## [1] 0.6666667
#If the patient has already waited 10 minutes, what is the probability that he/she will wait at least another 5 minutes prior to being seen?
(15-10)/(30-0)
## [1] 0.1666667
#What is the expected waiting time
(30-0)/2
## [1] 15
  1. Your hospital owns an old MRI, which has a manufacturer’s lifetime of about 10 years (expected value). Based on previous studies, we know that the failure of most MRIs obeys an exponential distribution. What is the expected failure time? What is the standard deviation? What is the probability that your MRI will fail after 8 years? Now assume that you have owned the machine for 8 years. Given that you already owned the machine 8 years, what is the probability that it will fail in the next two years?

\(\lambda\) = \(\frac{1}{\mu}\)

lambda_mri <- 1/10
#Expected Value = 0.1
std_mri <- sqrt(1/lambda_mri**2)
print(std_mri)
## [1] 10
print(exp(-1*lambda_mri*8))
## [1] 0.449329
qexp(8,rate=lambda_mri)
## Warning in qexp(8, rate = lambda_mri): NaNs produced
## [1] NaN
# Due to memoryless property of the exponential distribution the first probability is incorrect and it does not matter how much time has passed
1-exp(-1*lambda_mri*10) - (1-exp(-1*lambda_mri*8))
## [1] 0.08144952
#The correct answer is:
1-exp(-1*lambda_mri*2)
## [1] 0.1812692