Re: Evaluating integrals

*To*: mathgroup at smc.vnet.net*Subject*: [mg66224] Re: Evaluating integrals*From*: Paul Abbott <paul at physics.uwa.edu.au>*Date*: Thu, 4 May 2006 05:21:28 -0400 (EDT)*Organization*: The University of Western Australia*References*: <e39jvr$clu$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

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