#pdf of poisson
dpois(5,lambda=4*0.5)
## [1] 0.03608941
#pdf of poisson
1 - ppois(3,lambda=4)
## [1] 0.5665299
Patients arrive at the doctor’s office according to Poisson distribution with \(\lambda = 4\)/hour.
#cdf of poisson
ppois(8,lambda=4*2)
## [1] 0.5925473
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=19,t_star=1,lambda=4,company_prob=0.25){
#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=company_prob)
}
return(the_prob)
}
#Try different t_stars so probability is below 0.5
calculate_probability(t_star=3)
## [1] 0.8380567
calculate_probability(t_star=3.3)
## [1] 0.7443518
calculate_probability(t_star=3.955)
## [1] 0.49914
Suppose the the pdf of a random variable \(x\) is \(f(x) = \dfrac{a}{(1-x)^{1/3}}\) for \(0 < x < 1\) and \(0\) for other values of x. (Note: There was a typo in the in-class exercise saying the interval is \(0 < x < 1\))
Integral of \(f(x)\) should be 1. So \(\int_0^1 f(x) dx = a*(-3/2(1-x)^{2/3})|_0^1 = 3a/2\). Then \(a = 2/3\).
Use the same integral \(\int_0^{3/4} f(x) dx = -(1-x)^2/3|_0^{3/4} = 1 - (1/4)^{2/3} = 0.603\)
Let \(X\) and \(Y\) be the random variables and \(f(x,y)\) is the probability density function of the joint distribution. Suppose \(f(x,y) = a(\dfrac{5x}{7} + \dfrac{9y^3}{2})\) if \(0<x<2\) and \(-1<y<1\) (0 otherwise).
a) \(\int^1_{-1} \int^2_0 a(\dfrac{5x}{7} + \dfrac{9y^3}{2}) dx dy = \int^1_{-1} a(\dfrac{5x^2}{14} + \dfrac{9xy^3}{2})dy|^2_0 = \int^1_{-1} a(\dfrac{10}{7} + 9y^3) dy\). (This is also \(h(y)\) if \(a\) is known.) \(a(\dfrac{10y}{7} + \dfrac{9y^4}{4})|^1_{-1} = a(20/7)\). In order to be a distribution it should be equal to 1. So \(a = 7/20\).
b) As given in (a) \(h(y) = 7/20*(\dfrac{10}{7} + 9y^3)\). So \(h(y<0.5) = \int^{0.5}_{-1} 7/20*(\dfrac{10}{7} + 9y^3) dy = 7/20*(\dfrac{10y}{7} + \dfrac{9y^4}{4})|^{0.5}_{-1} = 0.0335\)
c) We need to find \(g(x) = \int^1_{-1} 7/20(\dfrac{5x}{7} + \dfrac{9y^3}{2})dy = x/2\). \(f(y|x) = f(x,y)/g(x)\).