R中正态分布函数的逆/逆。

时间:2021-08-27 01:16:46

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

在R中绘制正态分布曲线,我们可以用:

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

R中正态分布函数的逆/逆。

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?

如果dnorm计算y作为x的函数,那么R是否有一个函数来计算x作为y的函数?如果不是,最好的方法是什么?

2 个解决方案

#1


6  

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)

R中正态分布函数的逆/逆。

#2


12  

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.

dnorm()做的是给你一个概率密度函数。如果你对它积分,你会得到一个累积分布函数(由pnorm()在R中给出),CDF的逆是由qnorm()给出的;这是统计中概念化的标准方法。

#1


6  

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)

R中正态分布函数的逆/逆。

#2


12  

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.

dnorm()做的是给你一个概率密度函数。如果你对它积分,你会得到一个累积分布函数(由pnorm()在R中给出),CDF的逆是由qnorm()给出的;这是统计中概念化的标准方法。