Skip to content

how to use quadrature to integrate some complicated functions

3 messages · JeffND, michael.weylandt at gmail.com (R. Michael Weylandt, David Winsemius

#
Hello to all,

I am having trouble with intregrating a complicated uni-dimensional function
of the following form

Phi(x-a_1)*Phi(x-a_2)*...*Phi(x-a_{n-1})*phi(x-a_n).

Here n is about 5000, Phi is the cumulative distribution function of
standard normal, 
phi is the density function of standard normal, and x ranges over
(-infty,infty).

My idea is to to use quadrature to handle this integral. But since Phi has
not cloaed form,
I don't know how to do this effeciently. I appreciate very much if someone
has any ideas about it.

Thanks!

Jeff

--
View this message in context: http://r.789695.n4.nabble.com/how-to-use-quadrature-to-integrate-some-complicated-functions-tp3996765p3996765.html
Sent from the R help mailing list archive at Nabble.com.
1 day later
Have you tried wrapping it in a function and using integrate()? R is pretty good at handling numerical integration. If integrate() isn't good for you, can you say more as to why?

Michael
On Nov 6, 2011, at 4:15 PM, JeffND <Zuofeng.Shang.5 at nd.edu> wrote:

            
#
On Nov 8, 2011, at 9:43 AM, R. Michael Weylandt wrote:

            
The density of a standard normal is very tractable mathematically. Why  
wouldn't you extract the arguments and sum them before submitting to  
integration ... which also might not be needed since pnorm could  
economically provide the answer. Perhaps with limits a, b:

suitable_norm_factor*
    pnorm(
      dnorm( sum(x-a_1, x-a_2, ..., x-a_{n-1}, x-a_n) ), a,  
lower.tail=FALSE) ) -
    pnorm(
      dnorm( sum(x-a_1, x-a_2, ..., x-a_{n-1}, x-a_n) ), b,  
lower.tail=FALSE) ) )
If efficiency is desired ... use mathematical theory to maximum extent  
before resorting to pickaxes.