To get an idea of the distribution, the code below generates 1 million rows of 5 random variables from 0 to 1 (uniform). Then for each row, the minimum is selected. Then a histogram is generated. As you can see, the distribution looks like the exponential distribution.
vec <- c(runif(1, 0, 1), runif(1, 0, 1), runif(1, 0, 1), runif(1, 0, 1),runif(1, 0, 1))
datalist <- list(vec)
count <- 2
while (count < 1000001)
{
vec <- c(runif(1, 0, 1), runif(1, 0, 1), runif(1, 0, 1), runif(1, 0, 1),runif(1, 0, 1))
datalist[[count]] <- vec
count = count + 1
}
minvals = c()
for(i in 1:length(datalist))
{
minvals[i] <- datalist[[i]][which.min(datalist[[i]])]
}
hist(minvals)
Geometric
P = 1/10 = 0.10 –> probability of machine failing in one year
Expected Value = 1/p = 1/.10 = 10 –> expected number of years to see first failure
Standard Deviation = sqrt((1-p)/p^2) = 9.49
p <- .10
round(sqrt((1-p)/p^2),2)
## [1] 9.49
Probability that machine will fail after 8 years –> machine does not fail during the first 8 years.
1 - probability machine fail within the first 8 years = .43
p_fail_year_1 = p
p_fail_year_2 = (1-p)^1 * p
p_fail_year_3 = (1-p)^2 * p
p_fail_year_4 = (1-p)^3 * p
p_fail_year_5 = (1-p)^4 * p
p_fail_year_6 = (1-p)^5 * p
P_fail_year_7 = (1-p)^6 * p
p_fail_year_8 = (1-p)^7 * p
P_fail_after_8_years <-
1 - (p_fail_year_1 + p_fail_year_2 + p_fail_year_3 + p_fail_year_4 + p_fail_year_5 + p_fail_year_6 + P_fail_year_7 + p_fail_year_8)
round(P_fail_after_8_years,2)
## [1] 0.43
Exponential
lambda = 1 failure every ten years = 1/10 = .10 failure every year
lambda <- .10
Expected value = 1/lambda = 1/.10 = 10
expected_value <- 1/lambda
expected_value
## [1] 10
Variance = (lambda)^-2
Standard deviation - sqrt(variance)
standard_deviation <- sqrt(lambda^-2)
standard_deviation
## [1] 10
P(X >(x=8)) = e^((-lambda)x) = e^((-.10)8) = .45
e <- exp(1)
round(e^(-.10*8),2)
## [1] 0.45
p = .10 –> probability of machine failing for the year n is not given in this case
Expected value = np = n(.10) Standard deviation sqrt(np(1-p)) = sqrt(n.10.90)
Probability machine fails after 8 years –> same as machine does not fail in first 8 years
p <- .10
round((1-p)^8, 2)
## [1] 0.43
1 failure in 10 years = .10 failure in a year
8 year period –> 8 * .10 = .8 occurrence lambda = .8 occurrence in 8 year period
0 occurrence of the event within 8 years
P(X=0) = ((lambda^x) * (e^-lambda))/ x! = .45
lambda <- .8
e <- exp(1)
round((lambda^0 * e^(-1*lambda)) / factorial(0), 2)
## [1] 0.45
Expected value is lambda = .8
Standard deviation = sqrt(lambda) = sqrt(.8) = 0.8944272
sqrt(.8)
## [1] 0.8944272