This is a graded in-class assignment. Show all your work in R Markdown files. Submit compiled Word files only.
Patients arrive at the doctor’s office according to Poisson distribution with \(\lambda = 2\)/hour.
Solution
#cdf of poisson
ppois(2,lambda=2*2)
## [1] 0.2381033
First let's define the problem. Define \(n_p\) as the number of patients and \(n_c\) is the number of company. We want \(n_p + n_c \ge 10\) with probability 50% or higher for a given \(t^*\). Or to paraphrase, we want \(n_p + n_c \le 9\) w.p. 50% or lower.
What is \(n_c\) affected by? \(n_p\). It is actually a binomial distribution problem. \(P(n_c = i|n_p) = \binom{n_p}{i} (0.5)^i*(0.5)^{n_p-i}\). It is even better if we use cdf \(P(n_c \le k|n_p) = \sum_{i=0}^{k} \binom{n_p}{i} (0.5)^i*(0.5)^{n_p-i}\).
We know the arrival of the patients is distributed with poisson. So, \(P(n_p = j|\lambda t^*) = \dfrac{e^{-\lambda t}(\lambda t)^j}{j!}\). So \(P(j + k \le N) = \sum_{a=0}^j P(n_p = a|\lambda t^*)*P(n_c \le N-a | n_p = a)\). Remember it is always \(n_c \le n_p\).
#Let's define a function
calculate_probability<-function(N=9,t_star=1,lambda=2){
#N is the max desired number of patients
the_prob<-0
for(n_p in 0:N){
the_prob <- the_prob + dpois(n_p,lambda=lambda*t_star)*pbinom(q=min(N-n_p,n_p),size=n_p,prob=0.5)
}
return(the_prob)
}
#Try different t_stars so probability is below 0.5
calculate_probability(t_star=2)
## [1] 0.8631867
calculate_probability(t_star=3)
## [1] 0.5810261
calculate_probability(t_star=3.3)
## [1] 0.4905249
Two friends (A and B) agree to meet on 4:00 PM. A usually arrives between 5 minutes early and 5 minutes late. B usually arrives between 5 minutes early and 15 minutes late. Their times of arrival are independent from each other.
Solution
Solution
\[P(X < x) = 1 - e^{-\lambda x}\]
\[P(X > x) = e^{-\lambda x}\]
The solution is 1 - no machine provides an answer within the hour \(1 - P(X_1 > 1, X_2 > 1, X_3 > 1)\).
\[1 - P(X_1 > 1, X_2 > 1, X_3 > 1) = 1 - e^{-\lambda_1 - \lambda_2 - \lambda_3}\]
1 - pexp(1,rate=3+4+6)
## [1] 0.000002260329
A pack of flour contains 1 kg of flour. Though a flour pouring machine has a standard deviation of 50 gr.
Solution
We have \(\mu = 1000,\ \sigma = 50\). Define \(\Phi(.)\) as the cdf of the standard normal distribution.
#a
pnorm(1075,mean=1000,sd=50)-pnorm(925,mean=1000,sd=50)
## [1] 0.8663856
#b
qnorm(0.9,sd=50)
## [1] 64.07758
#c
1000-qnorm(0.05,sd=50)
## [1] 1082.243
Integral of \(f(x)\) should be 1. So \(\int_0^1 f(x) dx = a*(-2(1-x)^{1/2})|_0^1 = 2a\). Then \(a = 1/2\).
plot(seq(0,1,by=0.01),0.5*(1-seq(0,1,by=0.01))^0.5)
Use the same integral \(\int_0^{1/4} f(x) dx = -(1-x)^1/2 dx = 1 - (3/4)^(1/2) = 0.134\)