Numerical problem in getting the product of two random variables

56 Views Asked by At

I am using some numerical methods to get the distribution of the product of two random variables. But if I swap the variables I think of as X and Y, I get different results. I am trying to figure if this is due to the numerical software, or if I am screwing up in my mathematical thinking.

From Wikipedia, one gets the following result for the pdf of Z = XY, which doesn't seem controversial:

$$f_Z(z) = \int_{-\infty}^{\infty}f_X(x) f_Y(\frac{z}{x})\frac{1}{|x|}dx$$

(See: https://en.wikipedia.org/wiki/Product_distribution)

Now, unless I am being thick-headed, X and Y should be interchangeable, so that

$$f_Z(z) = \int_{-\infty}^{\infty}f_Y(y) f_X(\frac{z}{y})\frac{1}{|y|}dy$$

But, since both y and x are dummy variables, this should be the same as

$$f_Z(z) = \int_{-\infty}^{\infty}f_X(\frac{z}{x}) f_Y(x)\frac{1}{|x|}dx$$

When I make that change in the code, however, I get a slightly different numerical result.

Am I being dim-witted here, and making some obvious error with all these x's and y's floating around, or is it - as I suspect - a software problem?