data_605_hw7

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

Answer: The goal is to find the distribution function of Y, where Y represents the minimum value of \(X_i\)s, which is uniformly distributed on the integers from 1 to k. The first thing that we should consider, is how many possible way the \(X_i\)s can be assigned values between 1 and k. Since each random variable \(X_i\) is uniformly distributed integers from 1 to k, thus k represents the count of possible values for each \(X_i\). The total number of entire collection of random variable is therefore \(k^n\). And that represents our denominator in the formula.

Next, we need to figure out the number of ways the \(X_i\)s can be assigned values between 1 and k with at least one of the \(X_i\) values being the minimum value, say \(j\), from the series. So, we can begin to assume that value is 1. The total number of ways of \(Y = 1\) is calculated by \(k^n - (k - 1)^n\) because \(k^n\) represents all the possibilities and \((k - 1)^n\) represents all the possibilities where none of the \(X_i\) variables are equal to 1. Use the same logic to look for \(Y = 2\), the total number of possibilities in which 2 is the minimum and occurs at least once is \(k^n - (k-2)^n - (k^n - (k - 1)^n)\).

We can repeat the same pattern indefinitely to find the numerator. It would be equal to \((k-j+1)^n - (k-j)^n\), for a minimum value of \(j\).

Together, the distribution function is defined as,

\[ 1 \leq j \leq k, f(j) = \frac{(k-j+1)^n-(k-j)^n}{k^n} \]

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

2a (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.)

p = .1
q = 8

prob <- pgeom(q, p, lower.tail = FALSE)

ev <- 1 / p

sd <- sqrt((1-p)/(p^2))

print(paste0(glue("Model as geometric distribution, the probability of failing after ", {q}, " years is about ", round({prob}*100, 1), "%")))
## [1] "Model as geometric distribution, the probability of failing after 8 years is about 38.7%"
print(paste0(glue("The expected value is ", {ev}, " years as it is also clearly stated in the beginning by the manufacturer")))
## [1] "The expected value is 10 years as it is also clearly stated in the beginning by the manufacturer"
print(paste0(glue("The standard deviation is ", round({sd}, 2), " years")))
## [1] "The standard deviation is 9.49 years"

2b (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.

prob <- pexp(q, p, lower.tail = FALSE)

ev <- 1 / p

sd <- sqrt((1/p)^2)

print(paste0(glue("Model as exponential distribution, the probability of failing after ", {q}, " years is about ", round({prob}*100, 1), "%")))
## [1] "Model as exponential distribution, the probability of failing after 8 years is about 44.9%"
print(paste0(glue("The expected value is ", {ev}, " years as it is also clearly stated in the beginning by the manufacturer")))
## [1] "The expected value is 10 years as it is also clearly stated in the beginning by the manufacturer"
print(paste0(glue("The standard deviation is ", round({sd}, 2), " years")))
## [1] "The standard deviation is 10 years"

2c (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)

prob = dbinom(x = 0, size = q, prob = p)

ev <- q * p

sd <- sqrt(q * p * (1 - p))

print(paste0(glue("Model as binomial distribution, the probability of failing after ", {q}, " years is about ", round({prob}*100, 1), "%. In this example, let's imagine that we have to flip a coin 10 times and the chance of getting a head in each flip is about ", {p}, ". The question can be defined as what is the probability of not getting a head in the first 8 flips")))
## [1] "Model as binomial distribution, the probability of failing after 8 years is about 43%. In this example, let's imagine that we have to flip a coin 10 times and the chance of getting a head in each flip is about 0.1. The question can be defined as what is the probability of not getting a head in the first 8 flips"
print(paste0(glue("The expected value is n * p, and in this case n is equal to ", {q}, " years, and p is equal to ", {p}, ". Therefore, the expected value is ", {ev})))
## [1] "The expected value is n * p, and in this case n is equal to 8 years, and p is equal to 0.1. Therefore, the expected value is 0.8"
print(paste0(glue("The standard deviation is ", round({sd}, 4))))
## [1] "The standard deviation is 0.8485"

2d (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.

prob <- ppois(q = 0, p)^q

ev <- q * p

sd <- sqrt(ev)

print(paste0(glue("Model as poisson distribution, the probability of failing after ", {q}, " years is about ", round({prob}*100, 1), "%. In this example, lambda = ", {p}, " and it represents the probability of failure in one single interval, i.e. a year. In order to find out the probability of 0 failure in 8 years straight, we have to multiply the probability, i.e. ppois(0, p), eight times")))
## [1] "Model as poisson distribution, the probability of failing after 8 years is about 44.9%. In this example, lambda = 0.1 and it represents the probability of failure in one single interval, i.e. a year. In order to find out the probability of 0 failure in 8 years straight, we have to multiply the probability, i.e. ppois(0, p), eight times"
print(paste0(glue("The expected value is equal to lambda, i.e. ", {p}, ". Since there are ", {q}, " trials, the expected value is equal to n * p, and therefore equal to ", {ev})))
## [1] "The expected value is equal to lambda, i.e. 0.1. Since there are 8 trials, the expected value is equal to n * p, and therefore equal to 0.8"
print(paste0(glue("The standard deviation is ", round({sd}, 4))))
## [1] "The standard deviation is 0.8944"