Homework 07

Week07 Problem Set -1
Solution

We are given that \(Y\) denotes the minimum of the \(X_is\). Suppose each independent random variable \(X_i\) has \(k\) possibilities.
To find the distribution function \(P(X = m)\) we need to do the following:
1) Count the number of ways we can assign \(X_1\), \(X_2\),…,\(X_n\) to values between \(m\) and \(k\) with \(at\) \(least\) \(one\) \(X_i\) being assigned to \(m\)
2) Count the total number of combinations to assign \(X_1\), \(X_2\),…,\(X_n\) to values between \(1\) and \(k\). This is \(k^n\).

Since \(k^n\) represents the total number of combinations. \((k-1)^n\) will represent the combinations where none of the \(X_i\) are equal to 1.

Therefore:
\(P(X = 1)\) = \(\frac{k^n - (k-1)^n}{k^n}\)

Similarly:
\(P(X = 2)\) = \(\frac{(k-2+1)^n - (k-2)^n}{k^n}\)
\(P(X = 3)\) = \(\frac{(k-3+1)^n - (k-3)^n}{k^n}\)

After generalization this for \((X = m)\), we get:

\(P(X = m)\) = \(\frac{(k-m+1)^n - (k-m)^n}{k^n}\)

Separator - 01
Week07 Problem Set -2
Solution (a) (Geometric)

There is 1 failure every 10 year.
\(p = \frac{1}{10} = 0.10\)
\(q = (1-p) = 0.90\)

\(P(T \leqslant n) = \displaystyle\sum_{i=0}^{n-1} q^{i}.p\)
\(P(T \leqslant 8) = p + p.q + p.q^2 + p.q^3 + p.q^4 + p.q^5 + p.q^6 + p.q^7\)
\(P(T \leqslant 8) = p (1 + q + q^2 + q^3 + q^4 + q^5 + q^6 + q^7)\)
\(P(T \leqslant 8) = (0.1) * (1 + 0.9 + 0.9^2 + 0.9^3 + 0.9^4 + 0.9^5 + 0.9^6 + 0.9^7)\)
\(P(T \leqslant 8) = (0.1) *(5.6953279) = 0.56953279\)
\(P(T > 8) = (1 - 0.56953279) = 0.43046721\)

Expected Value is \(\frac{1}{p}\) = \(\frac{1}{0.10}\) = \(10\) years
Standard Deviation is \(\sqrt{\frac{q}{p^2}} = \sqrt{\frac{0.9}{0.01}} = \sqrt{90} = 9.4868\) failures


# Compute this manually
p <- 1/10
q <- (1-p)
n <- 8

p_geometric1 <- 0
sum <- 0
for (i in 1:n) {
  sum <- sum + (p*q^(i-1))
}

p_geometric1 <- (1-sum)
p_geometric1
## [1] 0.4304672
# Compute this using R function dgeom
p_geometric2 <- 1-pgeom(n-1, p) 
p_geometric2
## [1] 0.4304672
expected_value_geometric <- 1/p
expected_value_geometric
## [1] 10
standard_deviation_geometric <- sqrt(q/p^2)
standard_deviation_geometric
## [1] 9.486833
print(c(p_geometric1, p_geometric2, expected_value_geometric, standard_deviation_geometric))
## [1]  0.4304672  0.4304672 10.0000000  9.4868330
Separator - 02a
Solution (b) (Exponential)

\(k = 8\)
\(\lambda = \frac{1}{10} = 0.1\)
\(P(T \leqslant 8) = 1 - e^{-\lambda k}\)
\(P(T > 8) = 1-(1-e^{-\lambda k}) = e^{-0.1*8} = e^{-0.8} = 2.718282^{-0.8}=0.4493289\)

Expected Value is \(\frac{1}{\lambda}\) = \(\frac{1}{0.1}\) = \(10\) years
Standard Deviation is \(\sqrt{\frac{1}{\lambda^2}} = \sqrt{\frac{1}{0.01}} = \sqrt{100} = 10\) failures

lambda <- 1/10
k = 8

# Compute this manually
p_exponential1 <- 1-(1-exp(-lambda*k))
p_exponential1
## [1] 0.449329
# Compute this using R function pexp
p_exponential2 <- pexp(k, lambda, lower.tail=FALSE)
p_exponential2
## [1] 0.449329
expected_value_exponential <- 1/lambda
standard_deviation_exponential <- sqrt(1/lambda^2)
  
print(c(p_exponential1, p_exponential2, expected_value_exponential, standard_deviation_exponential))  
## [1]  0.449329  0.449329 10.000000 10.000000
Separator - 02b
Solution (c) (Binomial)

\(b(n,p,k)\) \(=\) \({n}\choose{k}\)\(p^k q^{n-k}\) \(where\) \(q = (1-p)\).
\(n = 8\)
\(p = 0.1\)
\(k = 0\)
\(b(8, 0.1, 0)\) \(=\) \({8}\choose{0}\)\((0.1)^0(1-0.1)^{(8-0)}\) \(where\) \(q = (1-0.1)\).
\(b(8, 0.1, 0)\) \(=\) \(1.1.(0.9)^8\)
\(0.4304672\)

Expected Value \(E[X]\) = \(np\) = \(8*0.1\) = \(0.8\) years
Standard Deviation is \(\sqrt{np(1-p)} = \sqrt{8*0.1*0.9} = \sqrt{0.72} = 0.8485\) failures

n <- 8
p <- 1/10
q <- (1-p)
k <- 0

# Compute this manually
p_binomial1 <- choose(n, k) * p^k * (1-p)^(n-k)
p_binomial1
## [1] 0.4304672
# Compute this using R function dbinom
p_binomial2 <- dbinom(k, n, p)
p_binomial2
## [1] 0.4304672
expected_value_binomial <- n * p
expected_value_binomial
## [1] 0.8
std_deviation_binomial <- sqrt(n*p*q)
std_deviation_binomial
## [1] 0.8485281
print (c(p_binomial1, p_binomial2, expected_value_binomial, std_deviation_binomial))
## [1] 0.4304672 0.4304672 0.8000000 0.8485281
Separator - 02c
Solution (d) (Poisson)

Since average number of failures in every 10 years is 1 so average number of failures in 8 years will be:

\(\lambda = \frac{8}{10} = 0.8\)
\(k = 0\)

Let X shows the number of failures in 8 years. So, the probability of 0 failures in 8 years will be:

\(P(X = 0) = \frac{\lambda^k}{k!}.e^{-\lambda} \approx \frac{0.8^0}{0!}.e^{-0.8} = e^{-0.8}\)
\(P(X = 0) = 0.4493\)

Expected Value is \(\lambda = 0.8\)
Standard Deviation is \(\sqrt{\lambda} = \sqrt{0.8} = 0.8944\) failures

lambda = 8/10
k <- 0
p_poisson1 <- (lambda^k/factorial(k))*(exp(-lambda))
p_poisson1
## [1] 0.449329
p_poisson2 <- ppois(0, lambda = 0.8)
p_poisson2
## [1] 0.449329
expected_value_poisson = 0.8
expected_value_poisson
## [1] 0.8
std_deviation_poisson = sqrt(expected_value_poisson)
std_deviation_poisson
## [1] 0.8944272
print (c(p_poisson1, p_poisson2, expected_value_poisson, std_deviation_poisson))
## [1] 0.4493290 0.4493290 0.8000000 0.8944272
Separator - 02d