Problem 1
Problem 1.a
knitr::opts_chunk$set(echo = TRUE)
# Given Data
Days_to_complete <- c(15,16,17,18,19,20,21)
Probability <- c(0.10,0.15,0.2,0.2,0.15,0.10,0.10)
# Create vector xValues and pmfValues
xValues <- Days_to_complete[Probability > 0]
pmfValues <- Probability[Probability > 0]
print(xValues)
## [1] 15 16 17 18 19 20 21
print(pmfValues)
## [1] 0.10 0.15 0.20 0.20 0.15 0.10 0.10
Problem 1.b
knitr::opts_chunk$set(echo = TRUE)
# Probability that the number of days it takes to complete an upcoming project is greater than or equal to 18
Probability_greater_than_or_equal_to_18 <- sum(Probability[Days_to_complete >=18])
print(Probability_greater_than_or_equal_to_18)
## [1] 0.55
Problem 1.c
knitr::opts_chunk$set(echo = TRUE)
# Expected value of X
Expected_value <- sum(xValues*pmfValues)
print(Expected_value)
## [1] 17.85
Problem 1.d
knitr::opts_chunk$set(echo = TRUE)
# Variance of X
Variance <- sum((xValues - Expected_value)^2 * pmfValues)
print(Variance)
## [1] 3.1275
Problem 2
knitr::opts_chunk$set(echo = TRUE)
#problem 2a
lambda <- 2
i <- 6
p_6_def <- dpois(i,lambda)
cat ( "Exactly 6 defects" , p_6_def)
## Exactly 6 defects 0.0120298
#problem 2b
p_atleast_6_def <- 1-ppois(i-1,lambda)
cat ("At least 6 defects", p_atleast_6_def)
## At least 6 defects 0.01656361
#problem 2c
p_atmost_3_def <- ppois(i-3,lambda)
cat ("At most 3 defects", p_atmost_3_def)
## At most 3 defects 0.8571235
#problem 2d
lambda <- 6
pr_6_def <- dpois(i,lambda)
pr_atleast_6_def <- 1-ppois(i-1,lambda)
pr_atmost_3_def <- ppois(i-3,lambda)
print ("All the above three solutions when average defect rate is 6 per 100")
## [1] "All the above three solutions when average defect rate is 6 per 100"
cat ( "Exactly 6 defects" , pr_6_def)
## Exactly 6 defects 0.1606231
cat ("At least 6 defects", pr_atleast_6_def)
## At least 6 defects 0.5543204
cat ("At most 3 defects", pr_atmost_3_def)
## At most 3 defects 0.1512039
Problem 3
Problem 3.a
knitr::opts_chunk$set(echo = TRUE)
#The local police department must write, on average, five tickets a day to keep department revenues at budgeted levels. Suppose the number of tickets written per day follows a Poisson distribution with a mean of 6.4 tickets per day.
#a. Find the probability that less than 6 tickets are written on a randomly selected day from this population.
#lambda = 6.4
P_lessthan_6 <- ppois(5,6.4, lower.tail=TRUE)
cat("Probability that less than 6 tickets are written on a randomly selected day is ",P_lessthan_6, "Or", round(P_lessthan_6*100,digits=2), "%")
## Probability that less than 6 tickets are written on a randomly selected day is 0.3837437 Or 38.37 %
Problem 3.b
knitr::opts_chunk$set(echo = TRUE)
#b. Find the probability that exactly 6 tickets are written on a randomly selected day from this population.
#lambda = 6.4
P_equal_6 <- dpois(6,6.4)
cat("Probability that exactly 6 tickets are written on a randomly selected day ",P_equal_6, "Or", round(P_equal_6*100,digits=2), "%")
## Probability that exactly 6 tickets are written on a randomly selected day 0.1585852 Or 15.86 %
Problem 3.c
knitr::opts_chunk$set(echo = TRUE)
#Find the probability that less than six but more significant than three tickets are written from this population on a randomly selected day.
#lambda = 6.4
P_lessthan_6 <- ppois(5,6.4)
P_upto_3 <- ppois(3,6.4, lower.tail = TRUE)
P_lessthan6_morethan3 <- P_lessthan_6 - P_upto_3
print(P_lessthan6_morethan3)
## [1] 0.2648249
#One more method
P_equal_4 <- dpois(4,6.4)
P_equal_5 <- dpois(5,6.4)
P_lessthan6_morethan3_2 <- P_equal_4 +P_equal_5
print (P_lessthan6_morethan3_2)
## [1] 0.2648249
cat("Probability that less than six but more significant than three tickets are written is ",P_lessthan6_morethan3, "Or", round(P_lessthan6_morethan3*100,digits=2), "%")
## Probability that less than six but more significant than three tickets are written is 0.2648249 Or 26.48 %
Problem 4
Problem 4.a
#Problem 4
## Problem 4.a
bulb_mean_lifetime <- 5
rate <- 1/bulb_mean_lifetime
prob_morethan7yrs <- 1 - pexp(7, rate,lower.tail = TRUE)
prob_morethan7yrs
## [1] 0.246597
Problem 4.b
#Problem 4
## Problem 4.b
bulb_mean.lifetime <- 5
prob_morethan4yrs <- 1 - pexp(4, rate = 1/bulb_mean.lifetime, lower.tail = TRUE )
prob_morethan4yrs
## [1] 0.449329
Problem 4.c
#Problem 4
## Problem 4.c
bulb_mean.lifetime <- 5
prob_morethan4yrs_after6yrs <- 1 - pexp(4, rate = 1/bulb_mean.lifetime,lower.tail = TRUE)
prob_morethan4yrs_after6yrs
## [1] 0.449329
Because the exponential distribution has memorylessness property,
the probability of a bulb that has been used for 6 years being used for
4 more additional years should be equal to the probability of a new bulb
being used for 4 years.