#####a. What is the probability that the time elapsed between two consecutive trades will be longer than 17 seconds?
knitr::opts_chunk$set(echo = TRUE)
#Given mean = 15
mu <- 15
Xval <- 13
p_left_tail <- 0.07
Z_left_tail <- qnorm (p_left_tail)
#Now Z = (X-mu)/sd
#sdev= (X - mu)/Z
sdev <- (Xval - mu)/Z_left_tail
prob_less_17 <- pnorm(17,mean=mu, sd=sdev)
prob_longer_17 <- 1- prob_less_17
cat( "probability that elapsed time is longer than 17 is ", prob_longer_17)
## probability that elapsed time is longer than 17 is 0.07
#
######b. What is the probability that the time elapsed between two consecutive trades will be between 13 and 14 seconds?
knitr::opts_chunk$set(echo = TRUE)
prob_less_13 <- pnorm(13, mean= mu, sd=sdev)
prob_less_14 <- pnorm (14, mean=mu, sd=sdev)
prob_13_14 <- prob_less_14 - prob_less_13
cat( "probability that elapsed time is between 13 and 14 seconds is ", prob_13_14)
## probability that elapsed time is between 13 and 14 seconds is 0.160289
#####c. What is the probability that the time elapsed between two consecutive trades will be between 15 and 16 seconds?
knitr::opts_chunk$set(echo = TRUE)
prob_less_15 <- pnorm(15, mean= mu, sd=sdev)
prob_less_16 <- pnorm (16, mean=mu, sd=sdev)
prob_15_16 <- prob_less_16 - prob_less_15
cat( "probability that elapsed time is between 15 and 16 seconds is ", prob_15_16)
## probability that elapsed time is between 15 and 16 seconds is 0.269711
seconds_80_prob <- qnorm (0.8, mean=mu, sd=sdev)
cat ("80% of the time the elapsed time between two trades will be: ", seconds_80_prob)
## 80% of the time the elapsed time between two trades will be: 16.14057