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 σ2 = 1/4. If Y1 = 100, estimate the probability that Y365 is :
n = 365
q = (100-100)/sqrt(n-1)
u = 0
var = 0.25
sd = sqrt(var)
pnorm(q,u,sd,lower.tail=FALSE)
## [1] 0.5
q = (110-100)/sqrt(n-1)
pnorm(q,u,sd,lower.tail=FALSE)
## [1] 0.1472537
q = (120-100)/sqrt(n-1)
pnorm(q,u,sd,lower.tail=FALSE)
## [1] 0.01801584
Calculate the expected value and variance of the binomial distribution using the moment generating function
The moment generating function for the binomial distribution is: \(\sum_{i=0}^n e^{xt} {n \choose x} p^{x} q^{(n-x)}\)
We see p and e{t} have the exponent x in common and can rearrange the function: \(\sum_{i=0}^n (pe^{t})^{x} {n \choose x}q^{(n-x)}\)
This simplies and results with: \(q^{n} + (pe^{t})^{n}\) \((q + pe^{t})^{n}\)
With the moment generating function, \(M_x(t)\), we know that the mean is \(M_x'(0)\) and the variance is \(M_x'(0) - M_x''(0)\).
\(mean = M_x'(t)\)
\(M_x'(t) = n(q + pe^{t})^{n-1}(pe^{t})\)
\(M_x'(0) = n(q + pe^{0})^{n-1}(pe^{0})\)
\(M_x'(0) = n(q + p)^{n-1}(p)\)
\(M_x'(0) = np(q + p)^{n-1}\)
Since we know, q = (1-p) therefore:
\(M_x'(0) = np((1-p) + p)^{n-1}\)
\(M_x'(0) = np(1)^{n-1}\)
\(M_x'(0) = np\)
This matches what we already know. The mean of the binomial distribution equals np.
\(variance = M_x''(0) - M_x'(0)^{2}\)
\(M_x'(t) = npe^{t}(q + pe^{t})^{n-1}\)
\(M_x''(t) = (n-1)(npe^{t})(q + pe^{t})^{n-2}(pe^{t}) + (npe^{t})(q + pe^{t})^{n-1}\)
\(M_x''(t) = (npe^{t})(q + pe^{t})^{n-2}(pe^{t})(n-1) + (npe^{t})(q + pe^{t})^{n-1}\) \(M_x''(t) = (npe^{t})(q + pe^{t})^{n-2} ((n-1)(pe^{t}) + (q + pe^{t}))\) \(M_x''(0) = (npe^{0})(q + pe^{0})^{n-2} ((n-1)(pe^{0}) + (q + pe^{0}))\) \(M_x''(0) = (np)(q + p)^{n-2} ((n-1)(p) + (q + p))\) \(M_x''(0) = (np)(q + p)^{n-2} (np - p + (q + p))\) \(M_x''(0) = (np)(q + p)^{n-2} (np + q)\)
Since we know, q = (1-p) therefore:
\(M_x''(0) = (np)(q + p)^{n-2}(np + q)\) \(M_x''(0) = (np)(1)(np + q)\) \(M_x''(0) = (np)(np + q)\)
\(variance = M_x''(0) - M_x'(0)^{2}\)
\(variance = (np)(np + q) - (np)^{2}\)
\(variance = (np)^{2}+ (npq) - (np)^{2}\)
\(variance = npq\)
Calculate the expected value and variance of the exponential distribution using the moment generating function
E[exp(tX)]
\(\int_\infty^{\infty} exp(tx) \lambda exp(- \lambda x) x~dx\)
\(\int_0^{\infty} exp(tx) \lambda exp(- \lambda x) x~dx\)
\(\lambda[1/t-(\lambda) exp((t-\lambda)x)]\)
\(\lambda[0 - 1/(t-\lambda)]\)
\(\lambda/(t-\lambda)\)
\(mean = M_x'(t)\)
\(M_x'(t) = \lambda/(\lambda-t)^{2}\)
\(M_x'(0) = \lambda/(\lambda-0)^{2}\)
\(M_x'(0) = \lambda/(\lambda)^{2}\)
\(M_x'(0) = 1/\lambda\)
\(variance = M_x''(0) - M_x'(0)^{2}\)
\(M_x'(t) = \lambda/(\lambda-t)^{2}\)
\(M_x''(t) = 2\lambda/(\lambda-t)^{3}\)
\(M_x''(t) = 2\lambda/(\lambda-0)^{3}\)
\(M_x''(t) = 2\lambda/(\lambda^{3}\)
\(M_x''(t) = 2/\lambda^{2}\)
\(variance = M_x''(0) - M_x'(0)^{2}\)
\(variance = 2/\lambda^{2} - 1/\lambda^{2}\)
\(variance = 1/\lambda^{2}\)