Formula for Bayesian probability for the situation when the positive test is actually positive \[P(A1|B)=\frac{P(B|A1)*P(A1)}{(P(B|A1)*P(A1)+P(B|A2)*P(A2))}\] B is when the test is positive
A1 is when there is HIV
A2 is when there is no HIV
P(B|A1)=0.96 the test postive for the case when there is actually HIV
P(A1)=0.001
P(B|A2)=0.02
P(A2)=0.999
B_A1 <- 0.96
A1 <- 0.001
B_A2 <- 0.02
A2 <- 0.999
A1_B <- B_A1*A1/(B_A1*A1+B_A2*A2)
A1_B
## [1] 0.04584527
The probability that an individual who is reported as positive by the new test actually has the disease is 4.58%
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?
treat <- 100000
test <- 1000
cases <- 100000
preval <- 0.001
false_pos <- 0.02
sens <- 0.96
The probability is 22.32% using formula \[P(X=2)=C_{2}^{24}*0.05^2*(1-0.05)^{24-2}=\frac{24!}{(24-2)!2!}*0.05^2*(1-0.05)^{24-2}=0.2232\]
months <- 24
probability <- 0.05
inspect <- 2
dbinom(inspect,months,probability)
## [1] 0.2232381
The chance to get X>2 or X=2 inspections is just we need to find the chance of 0, 1 inspections and subtract it from 1.
The probability is 33.92% using formulas below: \[P(X=0)=C_{0}^{24}*0.05^0*(1-0.05)^{24-0}=\frac{24!}{(24-0)!0!}*0.05^0*(1-0.05)^{24-0}=0.292\] \[P(X=1)=C_{1}^{24}*0.05^1*(1-0.05)^{24-1}=\frac{24!}{(24-1)!1!}*0.05^1*(1-0.05)^{24-1}=0.369\] \[P(X\geq 2)=1 -(P(X=0)+P(X=1))=0.339\]
months <- 24
probability <- 0.05
1-(dbinom(0,months,probability)+dbinom(1,months,probability))
## [1] 0.3391827
Using previous calculations below, the probability is 66.08% \[P(X<0)=P(X=0)+P(X=1)=0.292+0.369=0.661\]
(dbinom(0,months,probability)+dbinom(1,months,probability))
## [1] 0.6608173
Expected number is 1.2, standard deviation is 1.068.
expect <- months*probability
expect
## [1] 1.2
std <- sqrt(probability*months*(1-probability))
std
## [1] 1.067708
The chance of 3 patients is 0.757%. \[P(X=3)=\frac{e^{-\mu}*\mu^X}{X!}=\frac{e^{-10}*10^3}{3!}=0.00757\]
dpois(3,10)
## [1] 0.007566655
The probability is 41.7%, in 8 hours there should be 10*8=80 patients. The standard deviation is 3.16.
1-ppois(10, 10)
## [1] 0.4169602
std <- sqrt(10)
std
## [1] 3.162278
72 patients can be accepted by 3 provider during the work day. In the previous problem we found that 80 patients can be accepted during 8 hr work day which means they should be able to accept 11.11% more patients (80/72*100%=111.11%). They should hire more people, maybe part-time to accept them.
The chance that he/she would have selected five nurses is 7.59%.
In the formula below:
N=30 - population, k=15 - nurses, n=6 - randomly selected samples, x=5 - nurses out of samples. \[h(x; N, n, k)=\frac{C^k_x( N-C^{N-k}_{n-x})}{NC^N_n}=0.0759\]
sent_nurse <- 5
trips <- 6
nurse <- 15
non_nurse <- 15
dhyper(sent_nurse,nurse,non_nurse,trips,log=FALSE)
## [1] 0.07586207
Since 15 of the subordinate’s workers are nurses and 15 are other than nurses, they should send 3 nurses and 3 non-nurses.
The probability that the driver will be seriously injured during the course of the year is 69.93%. In the course of 15 months, 77.73%. The expected number of hours that a driver will drive before being seriously injured is 999. The probability that he or she will be injured in the next 100 hours is 2.86%
Chance of getting injured per hour is 0.001, 1200 hours in a year. \[P=1-q^{1200}=1-(1-0.001))^{1200}=69.89\] \[Hours=\frac{1-0.001}{0.001}=999\]
injured_1200 <- pgeom(q=1200 ,prob=0.001)
injured_1500 <- pgeom(q=1500 ,prob=0.001)
injured_1200
## [1] 0.6992876
injured_1500
## [1] 0.7772602
injured_1300 <- pgeom(q=1300 ,prob=0.001)
injured_1300 - injured_1200
## [1] 0.02863018
Poisson probability. The probability that the generator will fail more than twice in 1000 hours is 8%. Expected value is 1. \[P(X>2)=1-P(0)-P(1)-P(2)=1-0.368-0.368-0.184=0.08\] \[P(X=2)=\frac{e^{-\mu}*\mu^X}{X!}=\frac{e^{-1}*1^2}{2!}=0.184\]
1-ppois(2, 1)
## [1] 0.0803014
The probability that this patient will wait more than 10 minutes is 66.67%, the probability that he/she will wait at least another 5 minutes is 75%, the expected waiting time is 15 minutes. Probability for Uniform distribution: \[P=\frac{20}{30-0}=0.667\]
min=0
max=30
1-punif(10, min, max)
## [1] 0.6666667
1-punif(15, min=10, max)
## [1] 0.75
expect <- (min+max)/2
expect
## [1] 15
Expected failure time is 10 years. The standard deviation is also 10 years as it equal to geometric mean of expected value. The probability that your MRI will fail after 8 years is 44.93%. The probability that it will fail in the next two years is 8.14%. Formula for exponential distribution: \[P=e^{-k/\mu}=e^{-8/10}=0.4493\]
exp_time <- 10
time<- 8
1-pexp(8,1/exp_time)
## [1] 0.449329
pexp(10,1/exp_time) - pexp(8,1/exp_time)
## [1] 0.08144952