s-news
[Top] [All Lists]

[S] integration

To: s-news <s-news@wubios.wustl.edu>
Subject: [S] integration
From: Stefano <stecalza@tin.it>
Date: Tue, 21 Sep 1999 16:26:34 +0200
Sender: owner-s-news@wubios.wustl.edu
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

<Prev in Thread] Current Thread [Next in Thread>