---
author: "Your name here"
title: "Math 365 Exam 2"
output: pdf_document
---

Please answer each problem as clearly and completely as you can.  Do not discuss these problems with other students, or anyone else but me. You may use your textbook, lecture notes, class materials (including those posted on the Math 365 website), and homework, but do not use other books, the internet, or any materials other than those directly associated with the course.  Please do feel free to ask me questions, either via email or coming by my office.  Show all work to demonstrate that you understand your answer. You may use R for any computations; submit either your R script or the pdf knit from your R markdown.

Exam is due Monday April 2 at the beginning of class. Late submissions will be penalized by 10 points per day. You may submit by emailing me your R markdown pdf or as a combination of paper and R work.

## Problem 1 (25pt) 

Consider the offspring distribution for a branching process given by $a_k=(\frac{1}{2})^{k+1}$ for $k\ge0$.

(a) Classify this branching process as subcritical, critical, or supercritical. Hint: take a derivative of each side of the formula for geometric series to get a formula to evaluate the series for the expected number of offspring.

(b) Find the extinction probability.

(c) Prove by induction that $G_n(s)=\frac{n-s(n-1)}{n+1-ns}$.

(d) Let $T$ be the first generation at which the population is zero. Using part (c), find the probability of going extinct at the $n$th generation: $\mathbb{P}(T=n)$. Simplify, and then use to determine $\mathbb{P}(T=1)$, $\mathbb{P}(T=2)$, and $\mathbb{P}(T=3)$.


## Problem 2 (20pt)  

Suppose two stores open at 10am on a particular day. Customers enter store A according to a Poisson process with rate 4 arrivals per hour and customers enter store B according to a Poisson process with rate 8 arrivals per hour. Assume that customers arrive at the two stores independently.

(a) At what time on average will the first customer enter store A?

(b) At what time on average will the first customer of the day enter either store?

(c) State the probability that the first customer to show up enters store A rather than store B.

(d) How long on average after opening before the two stores together have five total customers?

(e) Find the probability that exactly 6 customers enter store A and 14 customers enter store B between 10am and noon.


## Problem 3 (20pt) 

Accidents occur at a busy intersection according to a Poisson process at the rate of two accidents per week. Three out of four accidents involve the consumption of alcohol.

(a) What is the probability that at least one accident occurs tomorrow?

(b) What is the probability that exactly three accidents involving alcohol will occur next week? (We don't care about the number of accidents not involving alcohol here.)

(c) If six accidents occur over a four-week period, what is the probability that less than half of them involve alcohol?


## Problem 4 (15pt) 

If $(N_t)_{t\ge0}$ is a Poisson process with parameter $\lambda$, find the probability generating function $G(s)=\mathbb{E}(s^{N_t})$. Simplify to a function not in terms of a series. Note that $G(s)$ will involve both $\lambda$ and $t$ as parameters.


## Problem 5 (20pt)  

Suppose the Metropolis-Hastings algorithm is used to simulate a binomial random variable $X$ with parameters $n=4$ and $p=1/4$: $\mathbb{P}(X=k)={4 \choose k}(\frac{1}{4})^k(\frac{3}{4})^{4-k}$ for $k=0,1,2,3,4$. The Markov chain used to generate proposal states is simple symmetric random walk on $\{0,1,2,3,4\}$ with reflecting boundaries.

(a) State the transition matrix $T$ used to generate proposal states.

(b) Find the transition matrix $P$ for the Markov chain created by the Metropolis-Hastings algorithm.

(c) Prove directly that the transition matrix $P$ gives a reversible Markov chain whose stationary distribution is the desired binomial distribution.