Processing math: 50%

Types of Probability Distribution Exercise

library(matlib)
library(MASS)

Prob 1

Let Y = min(X1,X2,X3,X4….Xn)

Also let F(y) be the CDF:

F(y) = P(Y≤y)

 = 1 - P(Y<y)
 
 = 1 - P(X1>y, X2>y, X3>y,...........Xn>y)
 
 = 1 - P(X1>y)*P(X2>y)*P(X3>y)....*P(Xn>y)
 
 = 1 - F(x1)*F(x2)*F(x3)*...........*F(xn)
   

Therefore, F(y) = 1 - [1k1k1k….1kn]

or F(y) = 1 - 1kn is the distribution for integer 1 to k


Prob 2a

Pr(X=k) = (1p)k p

for k = 0, 1, 2, 3, 4…..

In our case, p is the first time machine breaks down =>1/10 Therefore In this case, the success of the event signifies the failure of a machine

p <- 1/10
q <- 1-p

Pr8 <- q^8 # k= 8 because we are looking for not failing in the frist 8 yrs
print("Prob will fail after 8 yrs")
## [1] "Prob will fail after 8 yrs"
print(round(Pr8,7))
## [1] 0.4304672
print("Expected value :")
## [1] "Expected value :"
print(E <- 1/p)
## [1] 10
print("Std Dev :")
## [1] "Std Dev :"
print(stddev<-sqrt((1-p)/p^2))
## [1] 9.486833

Prob 2b

f(X=k) = expλ(-x) for x >= 0 and is zero for x < 0

lambda <- 1/10
x <-8 #after 8 years 

fx <- exp(-lambda*x) # for x >= 8 years
print('Prob will fail after 8 yrs')
## [1] "Prob will fail after 8 yrs"
print(fx)
## [1] 0.449329
print("Expected value :")
## [1] "Expected value :"
print(E<-1/lambda)
## [1] 10
print("Std Dev :")
## [1] "Std Dev :"
print(E<-sqrt(1/(lambda^2)))
## [1] 10

Prob 2c

Pr(X=k) = \binom{n}{k}p^{k}(1-p)^{n-k} for k = 0,1,2…

whereby, \binom{n}{k} = \frac{n!}{(n-k)!k!}

n <-8 # The numuber of years where there's no failures
k <-0 # Here K is the number of failure occurances (or zero sucesses)
p <-1/10 # Probability of failing in 10 years


Prbinomial <- choose(n,k)*p^k*(1-p)^(n-k)
print('Prob will fail after 8 yrs')
## [1] "Prob will fail after 8 yrs"
print(Prbinomial)
## [1] 0.4304672
Ebinomial <- n*p
Varbinomial <- n*p*(1-p)
print("Expected Value :")
## [1] "Expected Value :"
print(Ebinomial)
## [1] 0.8
print("Std. Dev :")
## [1] "Std. Dev :"
print(sqrt(Varbinomial))
## [1] 0.8485281

Prob 2d

Pr(X=k) = \lambdaexp(-\lambda)/k! for k = 0,1,2…to infinity

lambdap <- .8 #here avg rate of "success" = rate of failures in 8 years was scaled from 1 out of 10 years
k <- 0 #zero "success" =  zero "machine failures"
Prpoission <- ((lambdap^k)*exp(-lambdap))/factorial(k)
print('Prob will fail after 8 yrs')
## [1] "Prob will fail after 8 yrs"
print(Prpoission)
## [1] 0.449329
Epoission <- lambdap
print("Expected Value :")
## [1] "Expected Value :"
print(Epoission)
## [1] 0.8
Varpoission <- lambdap
print("Std. Dev :")
## [1] "Std. Dev :"
print(sqrt(Varpoission))
## [1] 0.8944272