MSDS Spring 2018

DATA 605 Fundamentals of Computational Mathematics

Jiadi Li

HW #7 - Distribution & Densities,Expected Value & Variance

1.Let \(X_1\),\(X_2\),…\(X_n\) be n mutually independent random variables, each of which is uniformly distributed on the integers from 1 to k. Let Y denote the minimum of the \(X_i\)s. Find the distribution of \(Y\).

\(P(Y = min\{X_1,X_2,...X_n\})\) = \(\frac{number\space of\space ways\space for\space Y = min\space of\space X_i}{number\space of\space possible\space outcomes}\)

Number of possible outcomes:
\(\because\) for each \(X_i\in [1,k]\), there are \(k\) possibilities,
\(\therefore\) total number of possible outomes (denominator of \(P(Y = min\{X_1,X_2,...X_n\})\)) is \(k^n\).

Suppose \(Y\) = 1, we need to exclude outcomes where \(X_i\neq1\) so that each \(X_i\in [2,k]\). The number of ways for \(Y = min\{X_1,X_2,...X_n\}\) is \(k^n-(k-1)^n\).

Similarly when \(Y\) = 2, we not only need to exclude outcomes where \(x_i\neq2\), but also need to exclude outcomes where \(X_i\le 1\).The number of ways for \(Y = min\{X_1,X_2,...X_n\}\) is \(k^n-(k-2)^n-[k^n-(k-1)^n]\) = \((k-1)^n-(k-2)^n\).

To generalize the answer, when \(Y\)=a, since all other terms are eliminated, the number of ways for \(Y = min\{X_1,X_2,...X_n\}\) is \((k-a+1)^n-(k-a)^n\).

As a result, \(P(Y = min\{X_1,X_2,...X_n\})\) = \(\frac{number\space of\space ways\space for\space Y = min\space of\space X_i}{number\space of\space possible\space outcomes}\) = \(\frac{(k-a+1)^n-(k-a)^n}{k^n}\).

2.Your organization owns a copier (future lawyers, etc.) or MRI (future doctors). This machine has a manufacturer’s expected lifetime of 10 years. This means that we expected one failure every ten years. (Include the probability statements and R Code for each part)

  1. What is the probability that the machine will fail after 8 years?. Provide also the expected value and standard deviation. Model as a geometric. (Hint: the probability is equivalent to not failing during the first 8 years.)

Geometric random variable:
\(p(k)=(1-p)^{k-1}p\) where \(k\) is the success trial
\(P(X>k)=(1-p)^k\)
\(E[X]=\frac{1}{p}\)
\(Var(X)=\frac{1-p}{p^2}\)

not failing during first 8 years = failing on the 9\(^{th}\) trial or later:
\(p\)=\(\frac{1}{10}\)
\(P(X>8) = (1-\frac{1}{10})^8\)

k <- 8
p <- 1/10
pgeom(k-1,p,lower.tail = FALSE)
## [1] 0.4304672

\(E[X]=\frac{1}{\frac{1}{10}}\)

1/p
## [1] 10

\(sd(X)=\sqrt\frac{1-\frac{1}{10}}{\frac{1}{10}^2}\)

sqrt((1-p)/p^2)
## [1] 9.486833


  1. What is the probability that the machine will fail after 8 years? Provide also the expected value and standard deviation. Model as an exponential.

Exponential random variable:
\(p(k)=\lambda e^{-\lambda k}\)
\(E[X]=\frac{1}{\lambda}\)
\(Var(X)=\frac{1}{\lambda^2}\)

\(P(X>8)=1-P(X\le8)=1-F(8)=1-(1-e^{(-\frac{1}{10})(8)})=e^{-\frac{4}{5}}\)

k <- 8
lambda <- 1/10
pexp(k,lambda,lower.tail = FALSE)
## [1] 0.449329

\(E[X]=\frac{1}{\frac{1}{10}}\)

1/lambda
## [1] 10

\(sd(X)=\sqrt\frac{1}{10^2}\)

sqrt(1/lambda^2)
## [1] 10


  1. What is the probability that the machine will fail after 8 years? Provide also the expected value and standard deviation. Model as a binomial. (Hint: 0 success in 8 years)

Binomial random variable:
\(p(k)=(_k^n)p^k(1-p)^{n-k}\) where \(r\) is the number of successes
\(E[X]=np\)
\(Var(X)=np(1-p)\)

\(n\)=8
\(k\)=0
\(p\)=\(\frac{1}{10}\)

n <- 8
k <- 0
p <- 1/10
pbinom(k,n,p)
## [1] 0.4304672

\(E[X]=(8)(0.1)\)

n*p
## [1] 0.8

\(sd(X)=\sqrt{(8)(\frac{1}{10})(1-\frac{1}{10})}\)

sqrt(n*p*(1-p))
## [1] 0.8485281


  1. What is the probability that the machine will fail after 8 years? Provide also the expected value and standard deviation. Model as a Poisson.

Poisson random variable:
\(p(k)=e^{-\lambda}\frac{\lambda^k}{k!}\)
\(E[X]=\lambda\)
\(Var(X)=\lambda\)

\(\lambda\)= number of failing expected in 8 years = \(\frac{1\space failing}{10\space years}\times 8\space years\) = \(\frac{4}{5}\)
\(X\) = number of failing within 8 years interval = 0
\(P(0)=e^{-\frac{4}{5}}\frac{(\frac{4}{5})^0}{0!}\)

k <- 0
lambda <- 4/5
ppois(0,4/5) 
## [1] 0.449329

\(E[X]=\lambda = \frac{4}{5}\)

lambda
## [1] 0.8

\(sd(X)=\sqrt\lambda = \sqrt\frac{4}{5} = \frac{2}{5}\sqrt5\)

sqrt(lambda)
## [1] 0.8944272