MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Evaluating integrals


In article <e39jvr$clu$1 at smc.vnet.net>, "masha" <mshunko at gmail.com> 
wrote:

> I am new to Mathematica and am tryong to figure out how to work
> efficently with integrals and run into the following issue. Let's say I
> want to integrate a simple function like Exp[-r b c], where c is a
> normal random variable. Doing this by hand, I can simply complete the
> square and end up with a simple result: Exp[(r^2 b^2 sc^2 )/ 2].

Computing the ExpectedValue of a function with respect to a specified 
distribution is available in the Statistics` packages.

After loading the package stubs,

  <<Statistics`

you can compute the ExpectedValue as follows:

 ExpectedValue[Function[c, Exp[-r b c]], NormalDistribution[mu, s]]

 Exp[(b^2 r^2 s^2)/2 - (b mu r)]

> However, if I run the following code in Mathematica:
> 
> g[c_] := PDF[NormalDistribution[µc, sc], c]
> pi = Exp[-r b c]
> FullSimplify[Integrate[pi g[c], c, Assumptions -> {c > 0, r > 0, b >
> 0}]]

Because you need to integrate over {c, -Infinity, Infinity}. 

  g[c_] = PDF[NormalDistribution[mu, s], c]

  Assuming[s > 0, Integrate[Exp[-r b c] g[c], {c, -Infinity, Infinity}]]

You will get exactly the same answer as above.

Cheers,
Paul

_______________________________________________________________________
Paul Abbott                                      Phone:  61 8 6488 2734
School of Physics, M013                            Fax: +61 8 6488 1014
The University of Western Australia         (CRICOS Provider No 00126G)    
AUSTRALIA                               http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: Faster Random Walk Simulation ?!?
  • Next by Date: Re: Selecting Many Things Rather Than Selecting One Thing From Many
  • Previous by thread: Re: Evaluating integrals
  • Next by thread: Re: Evaluating integrals