R 是否有类似于 Mathematica 中的 TransformedDistribution 的东西?
Does R have something similar to TransformedDistribution in Mathematica?
我有一个随机变量 X
和一个变换 f
,我想知道 f(X)
的概率分布函数,至少是近似的。在 Mathematica 中有 TransformedDistribution,但我在 R 中找不到类似的东西。正如我所说,某种近似解也可以。
您可以查看 distr
包。例如,假设 y = x^2+2x+1
,其中 x
服从均值为 2 标准差为 5 的正态分布。您可以:
require(distr)
x<-Norm(2,5)
y<-x^2+2*x+1
#y@r gives random samples. We make an histogram.
hist(y@r(10000))
#y@d and y@p are the density and the cumulative functions
y@d(80)
#[1] 0.002452403
y@p(80)
#[1] 0.8891796
我有一个随机变量 X
和一个变换 f
,我想知道 f(X)
的概率分布函数,至少是近似的。在 Mathematica 中有 TransformedDistribution,但我在 R 中找不到类似的东西。正如我所说,某种近似解也可以。
您可以查看 distr
包。例如,假设 y = x^2+2x+1
,其中 x
服从均值为 2 标准差为 5 的正态分布。您可以:
require(distr)
x<-Norm(2,5)
y<-x^2+2*x+1
#y@r gives random samples. We make an histogram.
hist(y@r(10000))
#y@d and y@p are the density and the cumulative functions
y@d(80)
#[1] 0.002452403
y@p(80)
#[1] 0.8891796