2016-06-19 5 views

答えて

3

distrパッケージを確認することができます。例えば、あなたがすることができ5. xは通常平均2、標準偏差と一緒に配布されたy = x^2+2x+1は、言う:

require(distr) 
x<-Norm(2,5) 
y<-x^2+2*x+1 
#[email protected] gives random samples. We make an histogram. 
hist([email protected](10000)) 
#[email protected] and [email protected] are the density and the cumulative functions 
[email protected](80) 
#[1] 0.002452403 
[email protected](80) 
#[1] 0.8891796 
+0

がよさそうです。しかし、yは負であってはならないので、私はy @ p(-1)= 0.08723655になります。 – frank

+1

私はこれに行き、式x^2 + 2 * x + 1が解釈されるように見えます*独立変数*、すなわち 'x^2'部分と' 2 * x'部分の合計が別々に取られているためです。 'y < - (x + 1)^ 2'を定義すると、正しい振る舞いを得ます。これは 'distr'メンテナの注意が必要だと思います。 – nicola

+1

素晴らしい、すべての仕事のおかげで。バグにもかかわらず、これは私が探していたものです。 – frank

関連する問題