Re: Unexpected expectation behaviour

*To*: mathgroup at smc.vnet.net*Subject*: [mg131088] Re: Unexpected expectation behaviour*From*: Donagh Horgan <donagh.horgan at gmail.com>*Date*: Tue, 11 Jun 2013 02:28:11 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*Delivered-to*: l-mathgroup@wolfram.com*Delivered-to*: mathgroup-outx@smc.vnet.net*Delivered-to*: mathgroup-newsendx@smc.vnet.net*References*: <komoio$1up$1@smc.vnet.net> <kopreb$cgj$1@smc.vnet.net>

On Thursday, June 6, 2013 12:22:51 PM UTC+1, Roland Franzius wrote: > Am 05.06.2013 09:15, schrieb Donagh Horgan: > > > Hi all, > > > > > > I've been playing around with the following expected value, but I've run into some odd behaviour with Expectation and NExpectation. The following example illustrates the problem: > > > > > > Expectation[Abs[y - 1]^3, > > > y \[Distributed] NoncentralChiSquareDistribution[1, s]] > > > Plot[{%, NExpectation[Abs[y - 1]^3, > > > y \[Distributed] NoncentralChiSquareDistribution[1, s]]}, {s, 0, > > > 10}] > > > > > > All advice greatly appreciated. > > > > Mathematica uses algebraic knowlegde about the parameters in MarcumQ > > function, the cumulative distribution > > > > CDF[ NoncentralChiSquareDistribution[1, s]] > > > > Take a trace > > > > Trace[Expectation[y - 1, > > y \[Distributed] NoncentralChiSquareDistribution[1, s]]]] > > > > and you will see an evaluation process typical for gaussian integrals. > > > > Unfortunately these procedures do not work for distributional > > observables like > > > > UnitStep[y-1]((y-1)^3) or Abs[(y-1)^3] > > > > and the like. > > > > In this cases one needs the primitive integrals over the density > > function explicitely. > > > > So Mathematica gets lost as usual in its unevaluted and never fully > > understandable evaluation processes of definite integrals. > > > > WRI should change this odd behaviour by just implementing a table lookup > > eg in > > Prudnikov/Marichev et al Tables. > > > > The big conceptual error is to let users fill in transformed variables > > just for fun instead of stating a certain algebraic type of integral and > > the transformation rules of arguments and parameters applied. > > > > A user friendly definite integrate processor should end the search with > > a comment and an Abort if the definite integral seems to be unknown. > > > > As a mathematical physicist, I am quite unhappy with WRI's "Integrate > > policy": Not to cite the sources and hiding algorithmic trivialities > > clear to the community just for fear of what? > > > > In the case of existing notation differences eg between > > Abramovitz/Stegun und body of the mathematical literature of function > > theory - eg in the case of elliptic functions - the Mathematica function > > body itself needs much more commentaries and hints in which cases to use > > which functions. > > > > -- > > > > Roland Franzius Great, thanks. That makes a lot of sense. The numerical method (using NExpectation) appears to be the correct one, so I'll stick with that for now, but it's worth bearing in mind for the future. I tend to think Mathematica is infallible (I know I shouldn't, but it's hard not to), and it's disconcerting to see obvious bugs like this.