Question 1 \(Bayesian\)

For this solution, we assume that all individuals \(100,000\) will at least receive the HIV test.

As shown in the diagram, our cost includes Cost of \(TEST\) for \(100,000\) individuals \(+\) cost of treatment for \(2,094\) individuals for the first year.

Testing Costs = $1000 X 100,000 = $\(100,000,000\)

Treatment Costs for \(2,094\) affected individuals = $\(100,000\) X \(2,094\)

Total Costs for testing of population and treatment of affected is $309,400,000

The Bayesian Tree is shown below -

grViz("
digraph dot {

graph [layout = dot,rankdir = LR,overlap = true, nodesep = .5, ranksep = .25,]

node [shape = box,
      style = filled,
      color = black,
      fixedsize = false,
      fontsize = 20,
      label = '']

node [fillcolor = red]
A

node [fillcolor = green]
B C

node [fillcolor = orange]
D E F G

edge [color = blue]

A [label = ' 100,000']
B [label = '100']
C [label = '99,900']
D [label = '96']
E [label = '4']
F [label = '97,902']
G [label = '1,998']

A -> B [label = '0.1% Prevelance Rate - POSITIVE']
A -> C [label = '99.9% - NEGATIVE']

B -> D [label = '96% Positive']
B -> E [label = '4% - False Positive']

C -> F [label = '98% Correct Negative']
C -> G [label = '2% - False Negative']

D -> G [label = 'Treatment Groups',dir=both,color=orangered,penwidth=5,fontsize=20]

}")

Question 2 - \(Binomial\)

# Using the dbinom function

pop <- 24

prob <- 0.05

insp <- 2

# the probability of receiving exactly 2 inspections in 24 months is :

print(dbinom(insp,pop,prob))
## [1] 0.2232381
# For the probability of receiving 2 or more inspections

insp2 <- 2:24

probs2 <- dbinom(insp2,pop,prob)

# Showing each inspection and the corresponding binomial probability

cbind(insp2,probs2)
##       insp2       probs2
##  [1,]     2 2.232381e-01
##  [2,]     3 8.616209e-02
##  [3,]     4 2.380795e-02
##  [4,]     5 5.012199e-03
##  [5,]     6 8.353665e-04
##  [6,]     7 1.130571e-04
##  [7,]     8 1.264455e-05
##  [8,]     9 1.183116e-06
##  [9,]    10 9.340386e-08
## [10,]    11 6.256718e-09
## [11,]    12 3.567427e-10
## [12,]    13 1.733163e-11
## [13,]    14 7.167214e-13
## [14,]    15 2.514812e-14
## [15,]    16 7.445167e-16
## [16,]    17 1.844004e-17
## [17,]    18 3.774278e-19
## [18,]    19 6.273038e-21
## [19,]    20 8.253997e-23
## [20,]    21 8.274684e-25
## [21,]    22 5.938768e-27
## [22,]    23 2.717972e-29
## [23,]    24 5.960464e-32
# The probability of having 2 or more inspections in 24 months is :

sum(probs2)
## [1] 0.3391827
# The probability of receiving fewer than 2 inspections is given by

insp3 <- 0:1

probs3 <- dbinom(insp3,pop,prob)

# Showing each inspection and the corresponding binomial probability

cbind(insp3,probs3)
##      insp3    probs3
## [1,]     0 0.2919890
## [2,]     1 0.3688282
# The probability of having fewer than 2 inspections in 24 months is :

sum(probs3)
## [1] 0.6608173
# The Expected number of inspections that should be received :

print(pop * prob)
## [1] 1.2
# The STD DEV is given by

sqrt(pop*prob*(1-prob))
## [1] 1.067708

Question 3 - \(Poisson\)

# The probability of exactly 3 patients arriving in 1 hour is given by ;

dpois(3,10)
## [1] 0.007566655
# The probability of more than 10 patients arriving in an hour is given by :

ppois(10,10, lower.tail=FALSE)
## [1] 0.4169602
# The number of patients expected in 8 ours with an observed rate of 
#10 per hour is :

print(10 * 8)
## [1] 80
# The standard deviation is always equal to the square root of the mean: σ = μ
print(sqrt(10))
## [1] 3.162278
# We observed 10 patients per hour, for 8 hours we will expect 80 patients
# Each Provider is seeing 3 patients per hour

# Over the course of 1 day the clinic is getting 8 more pateints than the 
# 3 providers can see.

3 * 3 * 8
## [1] 72
# Recommendation - The clinic needs to bring on an additional provider for 3 
# hours per day working at the rate of seeing 3 patients per hour to 
# cover the 10 patients per hour capacity

#Total capacity in 8 hours 

8 * 10
## [1] 80
#Total provider hours available with additional provider for 3 hours :

24 * 3 + (3 * 3)
## [1] 81

Question 4 - \(Hypergeometric\)

# Using the dhyper() function - dhyper(x, m, n, k, log = FALSE)

x <- 5
m <- 15
n <- 15
k <- 6
dhyper(x,m,n,k,log=FALSE)
## [1] 0.07586207
# The Expected number of nurses is given by E(X)=KM/N expected number of nurses

k * m/(n+m)
## [1] 3
# If we expect 3 nurses to get selected and there are 6 trips then,
# we can expect the number of non-nurses to be :

6-3
## [1] 3

Question 5 - \(Geometric\)

# We are required to calculate the probability of the driver being injured 
# while driving through the same area 1200 times in a year.
# The probability of injury is 0.1% = 0.001 every time the driver goes through
# that area, each trip is an independent event with the probability of 0.001
# that the driver will be injured in each of the 1200 hours(events). - Bernoulli

p = 0.1/100

k = 1200

# The probability of the driver having an accident during each of the 1200 trips
# is given by :

p^k
## [1] 0
# The probability of the driver having an accident during the 1200 trips is :

pgeom(k-1,p)
## [1] 0.6989866
# The probability of an accident in 15 months, note that the probability per
# event is the same in this case :

k_1 = k+300

pgeom(k_1-1,p)
## [1] 0.7770372
# The Expected number of hours that a driver will drive before being 
# seriously injured is given by :

p^-1
## [1] 1000
# The probability that the driver will be injured in the next 100 hours after
# driving 1200 hours is given by

(pgeom(1300-1,p)) - (pgeom(1200-1,p))
## [1] 0.02865884

Question 6

# The probability that the generator will fail more than twice in 1000 hours
# is is as follows - NOTE we use lower = false since we want > 2

ppois(2,1, lower=FALSE)
## [1] 0.0803014
# The epected value is given by :

(ppois(1,1))^-1
## [1] 1.359141

Question 7

# This problem uses the Uniform Distribution Concept, function punif;

a <- 0
b <- 30
x <- 10
x_1 <- 15


# The probability that this patient will wait more than 10 minutes is given by :
# We user the lower tail option since we want the >10 minutes probability

punif(x,a,b,lower.tail=FALSE)
## [1] 0.6666667
# The probability that the patient will wait another 5 mins after 
# waiting 10 mins is given by :

(punif(x_1,a,b)) - (punif(x,a,b))
## [1] 0.1666667
# The expected value of a uniform range is the same as it's mean given by :
#Expected time  for this distribution is ;

(30-0)/2
## [1] 15

Question 8

# The expected failure time is the same as the warranty time = 10 years

# For a geometric distribution, the 
# STD DEV = geometric mean of expected value = 10

# To compute the probability of the MRI machine failing after 8 years we use the 
# pexp function

exp_ft <- 10
time <- 8
time_2 <- 10

pexp(time,(1/exp_ft),lower.tail=FALSE)
## [1] 0.449329
# The probability of the MRI machine failing 
# between years 8 and 10 is given by :

(pexp(time_2,(1/exp_ft))) - (pexp(time,(1/exp_ft)))
## [1] 0.08144952

References

https://rich-iannone.github.io/DiagrammeR/graphviz_and_mermaid.html

https://graphviz.org/docs/attrs/dir

https://www.sciencedirect.com

https://www.calculator.net