The reverse/inverse of the normal distribution function in R

 ̄綄美尐妖づ 提交于 2021-02-06 11:00:45

问题


To plot a normal distribution curve in R we can use:

(x = seq(-4,4, length=100))
y = dnorm(x)
plot(x, y)

enter image description here

If dnorm calculates y as a function of x, does R have a function that calculates x as a function of y? If not what is the best way to approach this?


回答1:


I'm not sure if the inverse of the density function is built in -- it's not used nearly as often as the inverse of the cumulative distribution function. I can't think offhand of too many situation where the inverse density function is useful. Of course, that doesn't mean there aren't any, so if you are sure this is the function you need, you could just do:

dnorminv<-function(y) sqrt(-2*log(sqrt(2*pi)*y))

plot(x, y)
points(dnorminv(y),y,pch=3)

enter image description here




回答2:


What dnorm() is doing is giving you a probability density function. If you integrate over that, you would have a cumulative distribution function (which is given by pnorm() in R). The inverse of the CDF is given by qnorm(); that is the standard way these things are conceptualized in statistics.




回答3:


The derivation of the inverse of the standard normal pdf is:



来源:https://stackoverflow.com/questions/19589191/the-reverse-inverse-of-the-normal-distribution-function-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!