1. Suppose people arrive at a bank with poisson rate \(\lambda = 4\) per hour.
    1. What is the probability that 5 people arrive in the first half hour?
    2. What is the probability that at least 3 people arrive in the first hour?
    Solution
  1. \(P(X = 5|\lambda t = 4*0.5)= \dfrac{e^{-\lambda t}(\lambda t)^5}{5!}\)
    #pdf of poisson
    dpois(5,lambda=4*0.5)
## [1] 0.03608941
  1. \(P(X \ge 3|\lambda t = 4) = 1 - P(X \le 3|\lambda t = 4) = 1 - \sum_{i=0}^3 \dfrac{e^{-\lambda t}(\lambda t)^i}{i!}\)$
    #pdf of poisson
    1 - ppois(3,lambda=4)
## [1] 0.5665299
  1. Patients arrive at the doctor’s office according to Poisson distribution with \(\lambda = 4\)/hour.

    1. What is the probability of getting less than or equal to 8 patients within 2 hours?
    2. Suppose each arriving patient has 25% chance to bring a person to accompany. There are 20 seats in the waiting room. At least many hours should pass that there is at least 50% probability that the waiting room is filled with patients and their relatives?
  1. \(P(X\le 8|\lambda t = 4*2)= \sum_{i=0}^8 \dfrac{e^{-\lambda t}(\lambda t)^i}{i!}\)
    #cdf of poisson
    ppois(8,lambda=4*2)
## [1] 0.5925473
  1. 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 20\) with probability 50% or higher for a given \(t^*\). Or to paraphrase, we want \(n_p + n_c \le 19\) 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=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
  1. 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\))

    1. Find the constant \(a\).
    2. Find cdf of F(X < 3/4).

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\)

  1. 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).

    1. Find \(a\).
    2. Find the marginal distribution of \(y\) (\(h(y)\)) and \(h(y<0.5)\).
    3. Find the conditional distribution of \(f(y|x)\).

    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)\).