## installed_and_loaded.packages.
## prettydoc TRUE
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.
order statistic: distribution of the minimum https://docs.google.com/document/d/1PqAoVuau_3if7ZJzd7dv8cNPT6n5PNjruk8Hulwjb8c/edit#heading=h.u8c5sr7jr4cj https://math.stackexchange.com/questions/786392/expectation-of-minimum-of-n-i-i-d-uniform-random-variables
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. Geometric
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..)
\[\begin{equation} P(X > 8) = \sum_{x>8}.1(1 - .1)^{x - 1} = 0.4493288 \end{equation}\] \[\begin{equation} E(X) = 1/.1 = 10 \end{equation}\] \[\begin{equation} \sigma = \sqrt{\frac{1 - .1}{.1^2}} = 9.486833 \end{equation}\]p <- 0.1
first_success <- 8
initial_failures <- first_success - 1
pgeom(initial_failures, p, lower.tail = F)
## [1] 0.4304672
CDF <- 1 - (1 - p)^first_success
1 - CDF
## [1] 0.4304672
(EX <- (1 - p)/p)
## [1] 9
(sigma <- sqrt((1 - p)/p^2))
## [1] 9.486833
# Convert to minutes for N, pi, t
(N <- 10 * 365.25 * 24 * 60)
## [1] 5259600
(pi <- 1/N)
## [1] 1.901285e-07
(t <- 8 * 365.25 * 24 * 60)
## [1] 4207680
# Geometric. P(X > t | pi) = 1 - P(X<=t | pi) #0.4493288
1 - pgeom(t, pi)
## [1] 0.4493288b. Exponential
What is the probability that the machine will fail after 8 years?. Provide also the expected value and standard deviation. Model as an exponential.
\[\begin{equation} P(X > 8) = \int_{8}^{\infty} \lambda e^{-\lambda x} = 0.449329 \end{equation}\] \[\begin{equation} E(X) = 10 \end{equation}\] \[\begin{equation} \sigma = \sqrt{1 / .1^2} = 10 \end{equation}\]x <- 8
lambda <- 0.1
pexp(x, lambda, lower.tail = F)
## [1] 0.449329
CDF <- 1 - exp(-lambda * x)
1 - CDF
## [1] 0.449329
(EX <- 1/lambda)
## [1] 10
(sigma <- sqrt(1/lambda^2))
## [1] 10
# Exponential. P(X >= t | lambda = pi) = 1 - P(X <= t | pi)
1 - pexp(t, pi) #0.449329
## [1] 0.449329c. Binomial
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)
\[\begin{equation} P(X > 8) = \left( \begin{array}{c} 8 \\ 0 \end{array} \right).1^x(1 - .1)^{8-0} = 0.4493289 \end{equation}\] \[\begin{equation} E(X) = 8 * .1 = .8 \end{equation}\] \[\begin{equation} \sigma = \sqrt{8 * .1 (1 - .1)} = \sqrt{0.72} = 0.8485281 \end{equation}\]p <- 0.1
n <- 8
x <- 0
dbinom(x, n, p)
## [1] 0.4304672
choose(p, x) * p^x * (1 - p)^(n - x)
## [1] 0.4304672
(EX <- n * p)
## [1] 0.8
(sigma <- sqrt(n * p * (1 - p)))
## [1] 0.8485281
# Binomial. P(X = 0 | N = t, pi = pi) # 0.4493289
dbinom(0, t, pi)
## [1] 0.4493289d. Poisson
What is the probability that the machine will fail after 8 years?. Provide also the expected value and standard deviation. Model as a Poisson.
\[\begin{equation} P(X > 8) = \sum_{x>8}\frac{10^xe^{-10}}{x!} = 0.449329 \end{equation}\] \[\begin{equation} E(X) = .8 \end{equation}\] \[\begin{equation} \sigma = \sqrt{.8} = 0.894427 \end{equation}\]x <- 0
T <- 8
p <- 0.1
lambda <- T * p
dpois(x, lambda)
## [1] 0.449329
lambda^x * exp(-lambda)/factorial(x)
## [1] 0.449329
(EX <- lambda)
## [1] 0.8
(sigma <- sqrt(lambda))
## [1] 0.8944272
# Poisson. P(X = 0 | lambda = pi, t)
dpois(0, pi * t) #0.449329
## [1] 0.449329