data_605_hw9

Q1

The price of one share of stock in the Pilsdorff Beer Company (see Exercise 8.2.12) is given by Yn on the nth day of the year. Finn observes that the differences Xn = Yn+1 − Yn appear to be independent random variables with a common distribution having mean μ = 0 and variance \(\sigma^2\) = 1/4. If Y1 = 100, estimate the probability that Y365 is

  1. \(>= 100\)
  2. \(>= 110\)
  3. \(>= 120\)
y1 = 100
y365 = c(100, 110, 120)
mu = 0
var = 364 * (1/4)
sd = sqrt(var)
diff = y365 - y1

results = lapply(diff, function(x) pnorm(x, mu, sd, lower.tail = FALSE)) %>% unlist %>% round(., 4)

print(glue("The probability that the Y365 is equal to or above $", y365[1], " is approximately ", results[1]*100, "%"))
## The probability that the Y365 is equal to or above $100 is approximately 50%
print(glue("The probability that the Y365 is equal to or above $", y365[2], " is approximately ", results[2]*100, "%"))
## The probability that the Y365 is equal to or above $110 is approximately 14.73%
print(glue("The probability that the Y365 is equal to or above $", y365[3], " is approximately ", results[3]*100, "%"))
## The probability that the Y365 is equal to or above $120 is approximately 1.8%

Q2

Calculate the expected value and variance of the binomial distribution using the moment generating function.

We need to find the moment generating function, then compute the first and second derivative of the derived MGF.

\[ M(t)=E(e^{xt})\\ =\sum _{ x=0 }^{ n }{ { e }^{ xt }\begin{pmatrix} n \\ x \end{pmatrix}{ P }^{ x }(1-p)^{n-x} } \\ =\sum _{ x=0 }^{ n }{ { e }^{ xt }{ p }^{ x }\begin{pmatrix} n \\ x \end{pmatrix}(1-p)^{n-x} } \]

let

\[ y={ e }^{ xt }{ p }\\ z=(1-p) \]

Then use the binomial coefficient

\[ =\sum _{ x=0 }^{ n }{ y^{x}\begin{pmatrix} n \\ x \end{pmatrix}z^{n-x} }\\ =\sum _{ x=0 }^{ n }{ \begin{pmatrix} n \\ x \end{pmatrix}y^{x}z^{n-x} }\\ =(y+z)^{n} \]

Then use it to write out the MGF

\[ M(t)=(e^{t}p+(1-p))^{n} \]

The expected value is the first derivative and the variance is the second derivative of the MGF.

Expected value

\[ \mu=M'(t)=n(e^{t}p+0)^{n-1}(e^{t}p)\\ M'(0)=np\\ \mu=np \]

Variance

\[ M''(t)=np+n^{2}p^{2}-np^{2}\\ \sigma^{2}=np(1-p) \]

Q3

Calculate the expected value and variance of the exponential distribution using the moment generating function

Basically, I just follow this youtube tutorial for this question.

https://www.youtube.com/watch?v=bj5WayaA4kU

We need to evaluate the integral for continuous distribution and that’s how the exponential distribution is defined.

The Moment generating function for continuous distribution is

\[ M_x(t)=E(e^tX)= \int_{-\infty}^{\infty}e^{tx}f_X(x)dx \]

And t minus lambda must be less than 0, or the function will blow up

\[ \begin{split} M_X(t) = \int_{-\infty}^{\infty}e^{tx}\lambda e^{-\lambda x}dx \\ =\lambda \int_{0}^{\infty}e^{(t-\lambda)x}dx \\ = \frac{\lambda}{t-\lambda}\ \end{split} \]

If \(X\) has MGF \(M_X(t)\), then

\[ E(X^n)=M_X^{(n)}(0) \\ where \\ M_X^{(n)}(0) = \frac{d^n}{dt^n}M_X(t)|_0 \]

Now take the first, second derivative to find the first, second moments

Expected Value

First Moment

\[ E(X) = M_X^{(1)}(0) = \frac{\lambda}{(\lambda-t)^2}|_{t=0} = \frac{1}{\lambda} \]

Variance

Second Moment

\[ E(X^2) = M_X^{(2)}(0) = \frac{2\lambda}{(\lambda-t)^3}|_{t=0} = \frac{2}{\lambda^2} \]

Based on the first and second moment, variance is

\[ var(X) = E(X^2) - [E(X)]^2 = \frac{2}{\lambda^2} - \frac{1}{\lambda^2} = \frac{1}{\lambda^2} \]