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 .
problem_1 <- function(k,n,trials=100000) {
  Y<-rep(0,trials)
  for (i in 1:trials) {
    x<-sample.int(k,size=n,replace=TRUE)
    Y[i]<-min(x)
  }
  return(Y)
}
par(mfrow=c(1,2))
k<-50
n<-15
hist(problem_1(k,n),breaks=60,main=paste("Simulation",sep=""),xlab="Y",xlim=c(1,k),col="darkorange")
pY<-((k-1:k+1)^n-(k-1:k)^n)/k^n
barplot(pY,main=paste("Theoretical",sep=""),xlab="Y",xlim=c(1,k),col=c("darkblue","red"))

par(mfrow=c(1,2))
k<-120
n<-8
hist(problem_1(k,n),breaks=60,main=paste("Simulation",sep=""),xlab="Y",xlim=c(1,k),col="deepskyblue")
pY<-((k-1:k+1)^n-(k-1:k)^n)/k^n
barplot(pY,main=paste("Theoretical",sep=""),xlab="Y",xlim=c(1,k), col=c("green","yellow"))

par(mfrow=c(1,2))
k<-40
n<-5
hist(problem_1(k,n),breaks=60,main=paste("Simulation",sep=""),xlab="Y",xlim=c(1,k),col="cyan")
pY<-((k-1:k+1)^n-(k-1:k)^n)/k^n
barplot(pY,main=paste("Theoretical",sep=""),xlab="Y",xlim=c(1,k), col=c("orange","darkgoldenrod1"))

par(mfrow=c(1,2))
k<-50
n<-20
hist(problem_1(k,n),breaks=60,main=paste("Simulation",sep=""),xlab="Y",xlim=c(1,k))
pY<-((k-1:k+1)^n-(k-1:k)^n)/k^n
barplot(pY,main=paste("Theoretical",sep=""),xlab="Y",xlim=c(1,k), col=c("greenyellow"))

  1. 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..)
pgeom(8, 0.1, lower.tail=FALSE)
## [1] 0.3874205
  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.
pexp(8, 0.1, lower.tail=FALSE)
## [1] 0.449329
  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,lower.tail=TRUE)
## [1] 0.4304672
  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.
ppois(0,0.1,lower.tail=TRUE)^8
## [1] 0.449329