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

dist <- function(a,b) {
  Y = c()
  for (i in 1:b){
    X <- runif(a)
    Y[i] = min(X)
  }
  return(Y)
}

Y <- dist(20, 500)

hist(Y,  breaks = 50)

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

  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..)
# For P(X > 8) using geometric distribution
pfail <- 1/10
pgeom(8, pfail, lower.tail=FALSE)
## [1] 0.3874205
# The probability that the machine will fail after 8 years is 0.387.
# The Expected value 
expval <- 1/pfail
expval
## [1] 10
# The Standard Deviation
pnotfail <- 1 - pfail
SD <- sqrt(pnotfail/(pfail^2))
SD 
## [1] 9.486833
# The Expected value is 10 and the standard deviation is 9.487
  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.
k <- 8 
lambda <- 1/10

Expo <- pexp(k, lambda, lower.tail=FALSE)
round(Expo,2)
## [1] 0.45
# The probability the machine will fail after 8 years using exponential distribution is 0.45
# The Expected value 
1/lambda
## [1] 10
# The Standard Deviation
sqrt(1/lambda^2) 
## [1] 10
# The Expected value is 10 and the standard deviation is 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)
pbinom(0, 8, 0.1)
## [1] 0.4304672
# The probability using a binomial distribution is 0.4305
n <- 8
p <- 0.1
q <- 1 - p

# The Expected value 
Exp <- n*p
Exp
## [1] 0.8
# The Standard Deviation
SD <- sqrt(n*p*q) 
SD
## [1] 0.8485281
# The Expected value is 0.8 and the standard deviation is 0.849
  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.
lambda <- 8/10
ppois(0, lambda = 0.8)
## [1] 0.449329
# The probability using a poison distribution is 0.449.
# The Expected value 
Exp <- lambda
Exp
## [1] 0.8
# The Standard Deviation
sqrt(Exp) 
## [1] 0.8944272
# The Expected value is 0.8 and the standard deviation is 0.894