[19276] in s-news-athena

home help back first fref pref prev next nref lref last post

[S] integration

daemon@ATHENA.MIT.EDU (Stefano)
Tue Sep 21 10:29:03 1999

Message-Id: <37E7959A.72B30561@tin.it>
Date: Tue, 21 Sep 1999 16:26:34 +0200
From: Stefano <stecalza@tin.it>
Mime-Version: 1.0
To: s-news <s-news@wubios.wustl.edu>
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


I'm a beginner user of Splus (version 4.5), so probably my query is too
trivial; anyway this is the problem: I need to compute the integral of
the following function in x

1/(sqrt(2*pi)*sqrt(varmu))*exp(-.5*((x-w)/sqrt(varmu))^2)

where   x~N(mu,varx)
	mu~N(0,varmu)
	w=x-mu
	and so w~N(mu,varx+varmu)

For the moment let's suppose varx=varmu=1 and mu=0.

I did this way:

integrand_function(x,varw=2,varmu=1)
{	
	w_sort(rnorm(length(x),0,sqrt(varw)))
	(1/(sqrt(2*pi)*varmu)*exp(-.5*((x-w)/varmu)^2))
		}



integrate(integrand,lower=-Inf,upper=Inf,subdivisions=1000)


Is it correct?

Thank you in advance.


Stefano Calza.

-- 
***********************************************
Stefano Calza
Istituto di Statistica Medica e Biometria
Università degli Studi di Milano
Via G. Venezian, 1
20133 Milano

tel. +39 02/2361302, 02/70600908
fax 02/2362930
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

home help back first fref pref prev next nref lref last post