CUNY Homework Assignment Week 7

Joel Park

1. Let \(X_1, X_2, ..., X_n\) 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 \(X_i\)’s. Find the distribution of \(Y\).

Reference: http://mathworld.wolfram.com/UniformDistribution.html

According to Wolfram, a “uniform distribution”, sometimes known as a rectangular distribution, is a distribution that has constant probability.

In other words, if one value was picked from \(X_1, X_2, ..., X_n\), they would all have an equal probability of being selected. Given that there are a total of \(n X\)’s, the probability of each \(X\) would be \(1/n\).

Let’s plot this out:

Given for every value of \(X\) between \(1\) to \(k\), and from what we have mentioned in the previous paragraph, we can visualize and see why the uniform distribution is also called the rectangular distribution. As stated in the question stem, \(Y\) denotes the minimum of the \(X_i\)’s between \(1\) to \(k\), let’s find the distribution of Y.

Given that the uniform distribution follows the law of probability, the sum of all probabilities for all possible values of \(X = 1\). Therefore, \(P(X = x) * (k - 1) = 1\). If we solve for \(P(X = x)\), \(P(X = x) = 1 / (k - 1)\) for \(1 \leq X \leq k\).

\[P(x) = \begin{cases} 0, & \text{if } x < 1 \\ 1/(k-1), & \text{if } 1 \leq x \leq k \\ 0, & \text{if } x > k \\ \end{cases}\]

To get the probability distribution of \(P(x)\), or the area under the curve, which in this case is a rectangle, we can simply take \((x - 1) * P(x)\), or…

\[P(x)Cumulative = \begin{cases} 0, & \text{if } x < 1 \\ (x-1)/(k-1), & \text{if } 1 \leq x \leq k \\ 1, & \text{if } x > k \\ \end{cases}\]

This is the distribution of Y.

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

Let’s first look up the geometric distribution equation, as well as its expected value and standard deviation. Reference: https://revisionmaths.com/advanced-level-maths-revision/statistics/geometric-distribution

Probability Density Function: \(P(X = x) = p(1 - p)^{x-1} = p(q)^{x-1}\)

Expected Value: \(E(X) = 1/p\)

Variance: \(Var(X) = q/p^2\), where \(q = 1 - p\).

However, we will need to extrapolate what \(p\) is from the information above. The survival rate of a machine per year is 9/10 or 90%.

# Define probability that machine will continue to survive each year
q <- .90

# Define the probability that the machine will failure each year
p <- .10

# What is the probability that the machine WILL fail after 8 years using the geometric distribution.
geometric_fail <- p * q**(8)

# What is the Expected Value?
expected_value <- 1/p

# What is the Standard Deviation
# Remember: Standard deviation == sqrt(Var(X))
std_geometric <- sqrt(q/(p**2))

print(paste0("The probability that the machine WILL fail after 8 years using the geometric distribution is: ", geometric_fail))
## [1] "The probability that the machine WILL fail after 8 years using the geometric distribution is: 0.043046721"
print(paste0("Expected Value: ", expected_value))
## [1] "Expected Value: 10"
print(paste0("Standard Deviation: ", std_geometric))
## [1] "Standard Deviation: 9.48683298050514"

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

Again, we will need to find the information for the exponential distribution. Reference: https://www.youtube.com/watch?v=6GWgY_PxwbA, https://www.statlect.com/probability-distributions/exponential-distribution

Exponential Cumulative Distribution

When \(X \leq k\), \(P (X \leq k) = 1 - e^{-k/\mu}\) When \(X \geq k\), \(P (X \geq k) = e^{-k/\mu}\) where \(\mu = 1/\lambda\).

Expected Value: \(E(X) = 1/\lambda\)

Standard Deviation: \(\sqrt{1/\lambda^2}\).

For this particular scenario, \(\mu = 10\) and \(\lambda = 1/10\). (Solve for \(\lambda\) in the above equation.)

# Calculating the probability using the exponential model
year <- 8
mu <- 10
lambda_exp <- 1/10
prob_exp <- exp(-1 * year / 10)

print(paste0("The probability that the machine will fail after 8 hours using the exponential model: ", prob_exp))
## [1] "The probability that the machine will fail after 8 hours using the exponential model: 0.449328964117222"
print(paste0("Expected Value (which is the same as mu): ", mu))
## [1] "Expected Value (which is the same as mu): 10"
print(paste0("Standard Deviation: ", sqrt(1/(lambda_exp**2))))
## [1] "Standard Deviation: 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)

Formulas. Reference: http://sphweb.bumc.bu.edu/otlt/mph-modules/bs/bs704_probability/bs704_probability7.html

Binomial Distribution Model: \(P(X"success") = {n \choose k} p^x(1-p)^{n-x}\)

Expected Value: \(E(X) = np\)

Standard Deviation: \(\sigma = \sqrt{np(1-p)}\)

# p defined as machine failure per year
p <- 0.1

# n is the number of years in total checking (which is 8)
n <- 8

# What is the probability that we will have 0 success in 8 years, in other words, that the machine will survive the first 8 years
prob_binomial <- choose(n, 0) * p^0 * (1-p)^(8)

# Calculate the expected value
exp_value <- n * p

# Calculate the standard deviation
std_dev <- sqrt(n*p*(1 - p))

print(paste0("The probability that the machine will fail after 8 years? Model as a binomial: ", prob_binomial))
## [1] "The probability that the machine will fail after 8 years? Model as a binomial: 0.43046721"
print(paste0("Expected value: ", exp_value))
## [1] "Expected value: 0.8"
print(paste0("Standard Deviation: ", std_dev))
## [1] "Standard Deviation: 0.848528137423857"

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

Reference: http://onlinestatbook.com/2/probability/poisson.html

Poisson Distribution Model: \(P(X = x) = \frac{e^{-\mu}\mu^x}{x!}\), where e is the base of natural logarithms, \(\mu\) is the mean number of “successes”, x is the number of “successes” in question.

Expected Value = \(\mu\)

Standard Deviation = \(\sqrt{\mu}\)

Here, \(\mu = 10\).

x <- 8
mu <- 10 # Expected lifetime of a machine
prob_poisson <- (exp(-1 * mu) * mu**x) / factorial(x)

print(paste0("The probability that a machine will fail after 8 years from the Poisson Distribution: ", prob_poisson))
## [1] "The probability that a machine will fail after 8 years from the Poisson Distribution: 0.11259903214902"
print(paste0("Expected Value: ", mu))
## [1] "Expected Value: 10"
print(paste0("Standard Deviation: ", sqrt(mu)))
## [1] "Standard Deviation: 3.16227766016838"