Data 605 HW 7

library(knitr)
library(rmdformats)

## Global options
options(max.print="81")
knitr::opts_chunk$set(
    message = FALSE,
    warning = FALSE,
    cache = TRUE,
    comment = NA,
    prompt = FALSE,
    tidy = TRUE
)
opts_knit$set(width=31)
# install.packages("visualize")
library(visualize)

library(ggplot2)

1.

Let X1, X2, . . . , Xn 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 Xi’s. Find the distribution of Y . 

Ans: Let \(X_i\) be a discrete Uniform dist. on (1,k).

P(\(X_i\) = x) = \(\frac{1}{k}\), x=1,…, k

\(P(X_{i} \leq x) = \sum _{y=1}^{x} \frac{1}{k} =\frac{x}{k}, \qquad x = 1,2,…,k\)

Thus, P(\(X_{i} > x\)) = 1 - \(\frac{x}{k}\)

P( Y \(\leq\) y) = P(min{\(X_{1},…,X_{n}\)} \(\leq y\) )

\[ \begin{multline*} \begin{split} &= 1 - P(min \left\{ X_{1},…,X_{n}\right \} \geq y) \\ &= 1 - (P(X_{i}>y))^{n} \\ &= 1 - (1 - \frac{y}{k})^{n} \end{split} \end{multline*} \]

P ( Y = y) = P ( Y \(\leq\) y) - P ( Y \(\leq\) y -1)

\[ \begin{multline*} \begin{split} &= 1 - (1 - \frac{y}{k})^{n} - (1 - (1 - \frac{y-1}{k})^{n})\\ &= - (1 - \frac{y}{k})^{n} + (1 - \frac{y-1}{k})^{n} \\ &= (\frac{k-y+1}{k})^{n} - (\frac{k-y}{k})^{n} \\ &= \frac{(k-y+1)^{n} - (k-y)^{n}}{k^n}, \qquad y = 1,2,...,k \end{split} \end{multline*} \]

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 expect one failure every ten years. (Include the probability statements and R Code for each part.). 

(a)

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

Ans: Let X be the geometric random variable where it defines the event the machine will fail after x years.

Probability of failure, p = 1/10 = .1

P( X > 8) \(\approx\) .43

n <- 8
p <- 0.1
pgeom(n - 1, p, lower.tail = FALSE)
[1] 0.4304672
visualize.geom(stat = 8, prob = 0.1, section = "upper")

E(X)= \(\frac{1}{p}\)=10

\(\sigma = \sqrt{\frac{q}{p^2}} = \sqrt{\frac{.9}{.01}} \cong 9.49\)

(b)

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

Ans: Let X be the exponential random variable where it defines the event the machine will fail after x years.

Probability of failure, \(\lambda\) = 1/10 = .1

P( X > 8) \(\approx\) .45

pexp(8, 0.1, lower.tail = FALSE)
[1] 0.449329
visualize.exp(stat = 8, theta = 0.1, section = "upper")

E(X)= \(\frac{1}{\lambda}\)=10

\(\sigma = \frac{1}{\lambda}=10\)

(c)

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)

Ans: Let X be the binomial random variable where it defines the times the machine will fail after 8 years.

P( X \(\leq\) 0) \(\approx\) .43

# size - number of trials
dbinom(x = 0, size = 8, 0.1)
[1] 0.4304672
visualize.binom(stat = 0, size = 8, prob = 0.1, section = "lower")

E(X)=np=8*0.1=0.8

\(\sigma = \sqrt{npq} = \sqrt{8\times.1\times(1-.1)} \cong .85\)

(d)

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

Ans: Let X be the poisson random variable where it defines the times the machine will fail after 8 years.

Normally, Probability of failure, \(\lambda\) = 1/10 = .1

But for 8 years, \(\lambda = 8 \times .1 = .8\)

P( X \(\leq\) 0) \(\approx\) .45

dpois(0, 0.8)
[1] 0.449329
visualize.pois(stat = 0, lambda = 0.8, section = "lower")

E(x) = .8

\(\sigma = \sqrt{.8} \cong 0.89\)