MathGroup Archive 2006

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

Search the Archive

Re: variance of product of random variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70147] Re: variance of product of random variables
  • From: "Ray Koopman" <koopman at sfu.ca>
  • Date: Thu, 5 Oct 2006 03:33:15 -0400 (EDT)
  • References: <efq5iv$2ap$1@smc.vnet.net>

Frank Brand wrote:
> Dear Mathematica friends,
>
> is there a hint to a work done with Mathematica calculating the variance of a
> product of two random variables that are normally distributed?
>
> Thanks in advance
> Frank

Here is a step-by-step derivation of the variance of a product
p = x*y for bivariate normal {x,y} with mean vector = {Mx,My}
and covariance matrix = {{Vx,Cxy},{Cxy,Vy}}.

Expectations are implemented manually using /. replacements.
The results are general except where noted.

In[1]:= p = (Mx + X)*(My + Y)  (* X = x - Mx, Y = y - My *)

Out[1]= (Mx + X)*(My + Y)

In[2]:= Expand[p]
        % /. X*Y -> Cxy
        Mp = % /. {X -> 0, Y -> 0}

Out[2]= Mx*My + My*X + Mx*Y + X*Y

Out[3]= Cxy + Mx*My + My*X + Mx*Y

Out[4]= Cxy + Mx*My

In[5]:= Expand[p^2]
        % /. X^2*Y^2 -> Vx*Vy + 2*Cxy^2  (* assumes normality *)
        % /. {X^2*Y -> 0, X*Y^2 -> 0}    (* assumes normality *)
        % /. {X^2 -> Vx, Y^2 -> Vy, X*Y -> Cxy}
        Mpp = % /. {X -> 0, Y -> 0}

Out[5]= Mx^2*My^2 + 2*Mx*My^2*X + My^2*X^2 + 2*Mx^2*My*Y +
        4*Mx*My*X*Y + 2*My*X^2*Y + Mx^2*Y^2 + 2*Mx*X*Y^2 + X^2*Y^2

Out[6]= 2*Cxy^2 + Mx^2*My^2 + Vx*Vy + 2*Mx*My^2*X + My^2*X^2 +
        2*Mx^2*My*Y + 4*Mx*My*X*Y + 2*My*X^2*Y + Mx^2*Y^2 + 2*Mx*X*Y^2

Out[7]= 2*Cxy^2 + Mx^2*My^2 + Vx*Vy + 2*Mx*My^2*X + My^2*X^2 +
        2*Mx^2*My*Y + 4*Mx*My*X*Y + Mx^2*Y^2

Out[8]= 2*Cxy^2 + 4*Cxy*Mx*My + Mx^2*My^2 + My^2*Vx + Mx^2*Vy +
        Vx*Vy + 2*Mx*My^2*X + 2*Mx^2*My*Y

Out[9]= 2*Cxy^2 + 4*Cxy*Mx*My + Mx^2*My^2 + My^2*Vx + Mx^2*Vy + Vx*Vy

In[10]:= Vp = Expand[Mpp - Mp^2]

Out[10]= Cxy^2 + 2*Cxy*Mx*My + My^2*Vx + Mx^2*Vy + Vx*Vy

That's the answer. There are various equivalent expressions.
One such, in terms of the raw moments, is

In[11]:= Simplify[ Vp == Mxy^2 + Mxx*Myy - 2*Mx^2*My^2 /.
         {Mxy -> Cxy + Mx*My, Mxx -> Vx + Mx^2, Myy -> Vy + My^2}]
Out[11]= True


  • Prev by Date: Re: Symbol and Pi and expressions evaluating to Pi
  • Next by Date: Re: Symbol and Pi and expressions evaluating to Pi
  • Previous by thread: Re: variance of product of random variables
  • Next by thread: Deriviation