Actually, qnorm(0.975) is not needed.
I used this code:
f <- function(lwr, upr){
c("mean"= (upr+lwr)/2,
"stddev" = (upr-lwr)/4,
"sdRound" =round((upr-lwr)/4,1)
)
}
f(2,3)
With this, I get the answers as:
mean stddev sdRound
2.50 0.25 0.20
I can't use the value rounded in R. The correct answer is 0.3 since 0.25 when rounded is 0.3.
When I plug this sd=0.3 in the below, I get the correct upperlimit (and also lower limit)
upperlimit = round(qnorm(0.95, mean=2.5, sd=0.3),0)
upperlimit =3
lowerlimit = round(qnorm(0.05, mean=2.5, sd=0.3))
lowerlimit =2
It works for smaller values of upper and lower limits
f(2,3)
f(6,9)
but for pairs like f(6,14). f(26,38), I get the correct lowerlimit and upperlimit values only if I add 0.5 to the sd derived using the function.
Not sure if this is the correct way of solving this.