# Deriving Formula for Marginal Distributions

I'm having trouble understanding exactly why when you have a two-dimensional random variable $$(X,Y)$$ and you want to find the marginal probability distribution of $$X$$, for example, you integrate the joint probability density function with respect to y. That is,

$$f_x=\int_{-\infty}^{\infty}f(x,y) \ dy$$

I understand its analogous form in the discrete case:

$$p(X=x_i)=\sum_j p(x_i,y_j)$$

because here you're just adding up the different ways $$X$$ can be $$x_i$$ (i.e., it can be $$x_i$$ when $$Y$$ is $$y_1$$ or $$y_2$$ etc.) but I don't get exactly what is being done by integrating with respect to $$y$$. What is being summed up? And how does it work when there are no distinct probabilities but only a probability density, in terms of adding up possibilities to "marginalize out" a variable?

The joint density $f_{XY}(x,y)$ is defined in terms of probability as $$\mathbb{P}((X,Y)\in A)=\int_A f_{XY}(x,y)\,\text{d}x\text{d}y$$ for all measurable sets $A$. When $A$ is of the special form $A=[a,b]\times[c,d]$, this translates as $$\mathbb{P}((X,Y)\in A)=\int_c^d\int_a^b f_{XY}(x,y)\,\text{d}x\text{d}y=\int_c^d\left\{\int_a^b f_{XY}(x,y)\,\text{d}x\right\}\text{d}y$$that is, as the integral in $y$ of a function of $y$ defined as$$g(y)=\int_a^b f_{XY}(x,y)\,\text{d}x$$In particular, when $a=-\infty$ and $b=+\infty$ you get that$$\mathbb{P}((X,Y)\in \mathbb{R}\times[c,d])=\int_c^d\int_{-\infty}^{+\infty} f_{XY}(x,y)\,\text{d}x\text{d}y$$which shows that$$\int_{-\infty}^{+\infty} f_{XY}(x,y)\,\text{d}x$$operates like a density for $Y$.
• There is not much difference with Riemann sums when $f$ is continuous or continuous by parts and when $A$ is a union or intersection of a collection of cubes $[a,b]\times[c,d]$, which is why I wrote this explanation for a single cube. – Xi'an Mar 18 '16 at 20:33
• So then how would I interpret $\sum f(x,y) \Delta y$ – Gabriel Mar 18 '16 at 20:35