install.packages(“combinat”) require(combinat)

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 -
Function for Y = Min(X1, X2,…Xn) = Xi, where Xi is the minimum value for all independent random variables

This function can be modelled as a binomial distribution where -

   Xi = successful trial (minimum value)
   X1 to Xi-1, Xi+1 to Xn = failed trials
   n = number of trials
   k = population size (total possible outcomes per trial)
   p = 1/k probability of success
   q = n-1/k probability of failure
   

Binomial distribution for Y is then -

    =  n!/(n-1)!1! * p^(1) * q^(n-1)
    =  n * p * q^(n-1)  
    =  n *  (1/k)* (n-1/k)^(n-1)
    =  n * (1/k) * (n-1)^(n-1)/k^(n-1)
    =  n * (n-1)^(n-1)/K^n
    


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

Answer -
Mean (failure of the machine) = 10 years
For geometric probability distribution mean = 1/p, 10 = 1/p, p = 1/10 (probabilty of failure)

#Standard deviation = ^
p = 0.10
SD = sqrt((1-p)/(p^2))
SD
## [1] 9.486833

Probability that the machine will fail after 8 years - Pr(x<=8) = (1-p)^8*p

#Probability of failure after 8 years (discrete) = 
p = 0.10
pr = 0
for (i in 1:8)
{
   pr = pr + (1-p)^i*p
}
1 - pr
## [1] 0.4874205

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.

Mean (failure of the machine) = 10 years
For exponential probability distribution mean = beta = 1/lambda = 1/10
standard deviation, for exponential distribution is also 1/lamba = 1/10
The cummlative distribution fucntion CDF) for an exponetial distribution is given as -
f(x,lambda) = 1 - e^(-lambdax), where x >= 0 and 0 where x < 0 f(8,1/10)= 1 - e^(-1/10(8)), for x = 8

#Probability of failure after 8 years (continuous) = 
pr = (1 - exp(1)^(-0.10*8))
1 - pr
## [1] 0.449329

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)

if there is 1 break-down in 10 years, p = 1/10 (1 ‘success’ in 10 tries (years)) n = 8 (numbr of trials (years))
expected value = mean = np = 8/10 = 0.90
standard deviation = sqrt(np(1-p))

#Standard deviation = ^
p = 0.10
n = 8
SD = sqrt(n*p*(1-p))
SD
## [1] 0.8485281

k = number of successes in n trials = 0 PMF Formula for binomial distribution - P(k,n.p) = p(X=0) = nCrK * p^k * (1-p)^n-k

#Probability of 8 straight failures without success
p = 0.10
n = 8
k =0
pr = choose(n, k)*p^k*(1-p)^(n-k)
pr
## [1] 0.4304672

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

For a Poisson distribution, lambda = rate/unit time = 1 machine breakdown per 10 years = expected value
Standard deviation is sqrt(lambda) = sqrt(1) = 1
Probability of k = 0 breakdowns in years 1 through 8

#Probability of 8 straight failures without success
p = 0.10
n = 8
k =0   #no breakdown is expected in 8 years
pr = (1^k*exp(1)^(-1))/factorial(k)  
pr
## [1] 0.3678794