MathGroup Archive 2008

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

Search the Archive

Re: symbolic Variance - Integration

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84593] Re: [mg84585] symbolic Variance - Integration
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 6 Jan 2008 05:53:58 -0500 (EST)
  • Reply-to: hanlonr at cox.net

Remove[a, eV, X, Y];

Integrate[f[x] + g[x], x] // Distribute

Integrate[f[x], x] + Integrate[g[x], x]

eV /: eV[x_?NumericQ] := x;
eV /: eV[x_ + y_] := eV[x] + eV[y];
eV /: eV[a_?NumericQ * x_] := a * eV[x];
eV /: eV[x_ * y_] := eV[x]*eV[y] + coVar[x, y];
coVar /: coVar[x_, x_] := var[x];
var /: var[x_] := eV[x^2] - eV[x]^2;
indep = coVar[__] :> 0;

a /: NumericQ[a] = True;

var[a*X*Y] // Simplify

a^2*(coVar[X^2, Y^2] + eV[X^2]*eV[Y^2]) - 
   a^2*(coVar[X, Y] + eV[X]*eV[Y])^2

var[a*X*Y] /. indep // Simplify

(-a^2)*(eV[X]^2*eV[Y]^2 - eV[X^2]*eV[Y^2])


Bob Hanlon

---- jess <cuaxie at gmail.com> wrote: 
> Hi there!
> 
> I came across a formula for variance of a product of random variables
> X and Y. The formula was given under the assumption that X and Y are
> independent, and there was a remark that without this assumption the
> formula is very complicated.
> 
> I thought to myslef, okay i have mathematica on my pc so let's see how
> complicated it is...
> 
> Then i realized that the only way to calculate variance in mathematica
> is to:
> - give a list of points (i.e. uniform discrete distribution)
> - give a specific distribution, and say, its parameters ( eg. normal
> or gamma dist.)
> 
> so there is no way to make a symbolic calculation using an arbitrary
> random variable...
> 
> Huuuh, so i thought okay variance and expected value are nothing but
> integrals so i can try to define my own function using integrals (i do
> not want to consider just discrete or continues random variables)...
> 
> and then i realized i can't even obtain that integration is additive
> i.e. from
> 
> Integrate[f[x] + g[x], x]
> 
> i could not get
> 
> Integrate[f[x], x] + Integrate[g[x], x]
> 
> (so my function for expected value would not even tell me that
> EValue(X+Y) = EValue(X) + EValue(Y)... not to mention about
> calculating Variance( XY) = ????.... )
> 
> Coming back to my original problem: how to make mathematica do this
> 
> In[1] =E[XY]
> Out[1]=E[X]E[Y]+Cov[XY]
> 
> and further
> 
> In[2]=Var[XY]
> In[2]= ??????????
> 
> Please I would appreciate absolutely any comment at all...
> 
> Jess
> 



  • Prev by Date: Re: Button Question?
  • Next by Date: Re: symbolic Variance - Integration
  • Previous by thread: Re: symbolic Variance - Integration
  • Next by thread: Re: symbolic Variance - Integration