Displaying 1 result from an estimated 1 matches for "stamod".
Did you mean:
statmod
2009 Jan 02
1
R: numerical integration problems
...P(300)
$correct
[1] 22.59924
$App.2
[1] NaN
$App.trans
[1] 18.85405
$App.gq
[1] 22.59924
#=========================================
P(500)
Error in integrate(num., 0, Inf) : non-finite function value
The code is included below:
P=function(n=1,howmany=500)
{
#you do need to have stamod
#howmany is used to set the number of points used for the gaussian quadriture
set.seed(1)
sigma=5
x=rnorm(n)*sigma
a=5
b=5
#the correct expectation
#===========================================================
correct=(b+sum(x^2)*.5)/(.5*n+a-1)
#Method 1
#=============...