简体   繁体   中英

R - Get X value for given Y value

I have a cumulative distribution function from a standard normal distribution and I have a given y value, which should be 0.95

dist <- function(x) pnorm(x,0,1)

How can I solve the equation 0.95 = dist(x) for x?

You can use the uniroot function as follows:

dist <- function(x) pnorm(x,0,1) - 0.95
uniroot(dist, interval = c(-1,4))

which would give you the same answer as qnorm(0.95,0,1).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM