0
$\begingroup$

We already know that X and Y are independent of each other and follow the standard normal distribution. I refer to this article to get the probability density of Z=XY.

$$f_Z(z)=\int_{-\infty }^{\infty } \frac{1}{2 \pi \left| t\right| }e^{-\frac{t^4+z^2}{2 t^2}} \, dt$$

I want to draw an image of the probability density function of Z=XY, but MMA is always running and cannot output graphics. How can I speed up the drawing speed of this function?

P[z_] := 1/(2 π)
   Integrate[
   1/(2 π*RealAbs[t])
     E^(-((t^4 + z^2)/(2 t^2))), {t, -∞, +∞}]
Plot[P[z], {z, -5, 5}, PlotRange -> Full]

But the following code can output images, I want to compare the images output by these two methods, thank you.

dist = TransformedDistribution[
   x y, {x \[Distributed] NormalDistribution[], 
    y \[Distributed] NormalDistribution[]}];
PDF[dist][x]
Plot[PDF[dist][x], {x, -1, 1}, Filling -> Axis, PlotRange -> Full]

enter image description here

$\endgroup$
5
$\begingroup$
Clear["Global`*"]

dist = TransformedDistribution[x*y,
  {x \[Distributed] NormalDistribution[],
   y \[Distributed] NormalDistribution[]}]

(* VarianceGammaDistribution[1/2, 1, 0, 0] *)

PDF[dist, x] // Simplify

(* Piecewise[{{BesselK[0, x]/Pi, 
       x >= 0}}, BesselK[0, -x]/Pi] *)

Plot[PDF[dist, x], {x, -3, 3}, PlotRange -> All, Filling -> Axis]

enter image description here

For the other approach, as pointed out by @xzczd use Set rather than SetDelayed so that you only calculate the integral once.

P[z_] = Assuming[Element[z, Reals],
  Integrate[1/(2 π*RealAbs[t]) E^(-((t^4 + 
           z^2)/(2 t^2))), {t, -∞, +∞}]]

(* BesselK[0, Abs[z]]/π *)

Plot[P[z], {z, -3, 3}, PlotRange -> All,
 Filling -> Axis]

enter image description here

| improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.