Search code examples
rreadr

Is there a specific R or python code to solve the below besides pnorm?


Let X ~ N (100, 202). Find two values, a and b, symmetric about the mean, such that the probability of the random variable taking a value between them is 0.99

I've used the below to look for the z-value pnorm(0.005)


Solution

  • Write a simple function implementing an inverse transformation from z-score to a normal variate.

    cinorm <- function(p = 0.95, mean = 0, sd = 1){
      q <- c((1 - p)/2, p + (1 - p)/2)
      z <- qnorm(q)
      x <- mean + sd*z
      x
    }
    
    cinorm(0.99, 100, 202)
    #[1] -420.3175  620.3175