Assignment 7

Week 7, Imp. Distributions / EX / VARX

Fundamentals of Computational Mathematics

CUNY MSDS DATA 605, Fall 2018

Rose Koh

10/13/2018
  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.

Y = min(X1, X2, … Xn)

n are mutually independentt random variables and uniformly distributed, meaning that there is no overlap or repetition in variables. Thus the distribution of Y is always count as 1 or probability of \(\frac{1}{n}\)

The number of possible combinations of \(X_i\) is \(k^n\) – choose n values out of k options with replacement.

Consider number of combinations with at least one 1.

P(Y = 1) = \(\frac{k((k-1)^n)}{k^n}\)

Consider the number of combinations with at least one 2 and no 1.

P(Y = 2) = \(\frac{k^n - (k^n - (k-1)^n) - (k-2)^n}{K^n}\) = \(\frac{k^n - k^n +(k-1)^n - (k-2)^n}{k^n}\) = \(\frac{(k-1)^n - (k-2)^n}{k^n}\)

Consider the number of combinations without 1 or 2 but at least one 3

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

Thus we can generalize this by

P(Y = a) = \(\frac{(k-a+1)^n - (k-a)n}{k^n}\)

k = 50
sample <- runif(k, min = 1, max = k)
Y = min(sample)
plot(sample)

hist(sample)


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

Cumulative Distribution Function (cdf) for the geometric distribution, \(F_X(k)=P(X\le k)=1-q^{k+1}\), where k is the number of failures before the first success. The R pgeom defines the geometric distribution this way.

Thus to calculate P(X > 8) using geometric distribution:

pgeom(8, 0.1, lower.tail = F)
## [1] 0.3874205

The expected value (number of years before the first machine fails) is

q <- 0.9
p <- 0.1
E.v <- q/p
E.v
## [1] 9

The standard deviation is \(\sigma^2 = \sqrt{q/p^2} = \sqrt{0.9/0.1^2} \approx 9.4868\).

sqrt(q/p^2)
## [1] 9.486833
  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.

For exponential distribution, CDF \(F_X(k) = P(X \le k) = 1-e^{-\lambda k}\), where \(\lambda\) is the rate parameter.

For the b example, \(\lambda = 0.1\).

pexp(8, 0.1, lower.tail = FALSE)
## [1] 0.449329

The expected value is \(E(X) = 1/\lambda = 1/0.1 = 10\)

The standard deviation is \(\sigma^2 = \sqrt{1/\lambda^2} = 1/\lambda = 10\)

  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)

For binomial distribution, \(P(X=k)= {n \choose k}p^k q^{n-k}\).

Probability of a machine failing after 8 years is equivalent to probability 0 successes after 8 trials.

Thus, for \(k=0\) and \(n=8\), \(P(X=0) = {8\choose0} 0.1^0 \times 0.9^{8-0} = 1 \times 1 \times 0.9^8 \approx 0.4305\).

pbinom(0,8,0.1,lower.tail=TRUE)
## [1] 0.4304672

The Expected value \(E(X)=np= 8 \times 0.1 = 0.8\)

The standard deviation \(\sigma^2 = \sqrt{npq} = \sqrt{8 \times 0.1 \times 0.9} \approx 0.8485\).

  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.

For Poisson distribution, \(P(X=k)=\frac{e^{-\lambda}\lambda^k}{k!}\)

Similar to the binomial distribution, the probability of a machine failurre after 8 years is the same as probability of 0 successes after 8 intervals.

\(P(X=0)^8 = (\frac{e^{-0.1} \times 0.1^0}{0!})^8 = (e^{-0.1})^8 \approx 0.4493\)

ppois(0, 0.1, lower.tail = TRUE)^8
## [1] 0.449329

The expected value \(E(X) = \sigma^2 = \lambda = 0.1\).

The standard deviation \(\sigma^2 = \sqrt{\lambda} = \sqrt{8 \times \frac{1}{10}} \approx 0.8944\).