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

```
n <- 100000 # Lets consider sample size of 100000
j <- 100
size <- 100
Y <- c()
for (i in 1:n){
Xn <- sample(1:j, size, TRUE)
Y <- c(Y, min(Xn))
}
hist(Y)
```

As we can see above this distribution is long tail right skewed.

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

```
p_fail = 1/10 # Prob. of failing
p_suc = 1-p_fail
n = 8
result = 1- pgeom(n-1,p_fail)
paste("The probability that the machine will fai after 8 years is:- ",round(result),4)
```

`## [1] "The probability that the machine will fai after 8 years is:- 0 4"`

`## [1] "Expected Value:- 10"`

`## [1] "Standard deviation is:- 9.4868"`

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

```
n = 8
p_life = 1/10
p_fail = pexp(n,p_life,lower.tail=FALSE)
paste("The probability that the machine will fail after 8 years is:- ", round(p_fail,4))
```

`## [1] "The probability that the machine will fail after 8 years is:- 0.4493"`

`## [1] "Expected Value:- 10"`

`## [1] "Standard deviation is:- 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)

```
b= 8
p = 1/10
q = 1- p
k = 0
p_binomial = dbinom(k,n,p)
paste("The probability that the machine will fail after 8 years is:- ", round(p_binomial,4))
```

`## [1] "The probability that the machine will fail after 8 years is:- 0.4305"`

`## [1] "Expected Value:- 0.8"`

`## [1] "Standard deviation is:- 0.8485"`

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

```
pois_lambda <- 8 * (1/10)
k <- 0
p_poison= ppois(0,pois_lambda)
paste("The probability that the machine will fail after 8 years is:- ", round(p_poison,4))
```

`## [1] "The probability that the machine will fail after 8 years is:- 0.4493"`

`## [1] "Expected Value:- 0.8"`

`## [1] "Standard deviation is:- 0.8944"`