0
$\begingroup$

I want to add two random variables, $X,Y$ together $Z=X+Y$. They may be correlated. The integral is $$f_z(z)=\int^{\infty}_{-\infty}\int^{z-x}_{-\infty}f_{x,y}(x,y)dxdy=\int_{-\infty}^{\infty}f_{x,y}(x,z-x)dx$$ where $f_z$ is the pdf of the new random variable $Z$ and $f_{x,y}$ is the joint pdf of the random variables $x,y$.

My problem is that I have two marginal distributions $f_x(x)$ and $f_y(y)$. I can estimate the joint pdf using a copula.

However, this is all done numerically. I have two arrays for $x$ and $y$, and two arrays for $f_x(x)$ and $f_y(y)$.

I can calculate the joint pdf using the copula method, but again it is numerical.

I wrote some code to test this using Gaussians since the solution is known and I can easily check if I am correct.

I first calculated the joint pdf in $x,y$. Then I created the Z array, $z=x+y$. And I integrated the joint pdf, which is a 2-d matrix, with respect to x and plotted it along the z array. But integrating along x is produces the same answer if I was still using a joint pdf in x and y. So this gave me a wrong answer.

I then tried to calculate the joint pdf in $x,z$ by converting the marginal distribution of $y$ to $x,z$. But this didn't work.

I finally tried to do the double integral and use the upper limit of $z-x$. But I couldn't get this to work correctly either.

It is possible that I have some bugs in my code and one of these solutions will work correctly.

It seems that this should be doable because if $f_{x,y}(x,z-x)=f_{x,z}(x,z)$ the 2d matrix I have should be the same. But maybe i'm wrong because z is a continuous variable, and those two functions are only equal if $z=x+y$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.