[英]Does R have something similar to TransformedDistribution in Mathematica?
I have a random variable X
and a transformation f
and I would like to know the probability distribution function of f(X)
, at least approximately. 我有一个随机变量
X
和一个变换f
,我想知道f(X)
的概率分布函数,至少近似。 In Mathematica there is TransformedDistribution, but I could not find something similar in R. As I said, some kind of approximative solution would be fine, too. 在Mathematica中有TransformedDistribution,但我在R中找不到类似的东西。正如我所说,某种近似解决方案也可以。
You can check the distr
package. 你可以检查一下
distr
包。 For instance, say that y = x^2+2x+1
, where x
is normally distributed with mean 2 and standard deviation 5. You can: 例如,假设
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.