Let Y ∼ Gamma(a; λ) , a, λ > 0: that means random variable Y has continuous density:
$$f_Y(y) = \begin{cases} \frac{\lambda^a y^{a-1} e^{-\lambda y}}{\Gamma(a)}, & y > 0, \\ 0, & \text{elsewhere.} \end{cases}$$
Let random variable X, conditional to Y have normal distribution with expected value 0 and variance 1/y, therefore
$$X|(Y=y) ∼ N(0; 1/y). $$
Find unconditional distribution for random variable X.
I know density function for X|Y looks like $$ f_{X|Y=y}(x) = \frac{\sqrt{y}}{\sqrt{2\pi}} e^{-\frac{1}{2} y x^2} $$
I belive I can caluclate joint density function as $f_{X,Y}(x,y)$ = $f_Y(y)* f_{X|Y}(x,y)$,but it doesn't look nice. Any ideas?
Perform the integration with respect to $y$ of the kernel of the joint density, discarding any constant multiplicative factors:
$$f_{X \mid Y}(x,y) f_Y(y) \propto y^{1/2} e^{-x^2 y/2} \cdot y^{a-1} e^{-\lambda y} = y^{a - 1/2} e^{-(x^2/2 + \lambda)y}.$$
This is the kernel of a gamma density with shape $a^* = a + 1/2$, and rate $\lambda^* = \lambda + \frac{x^2}{2}$. So
$$f_X(x) = \int_{y=0}^\infty f_{X \mid Y}(x,y) f_Y(y) \, dy \propto \frac{\Gamma(a+1/2)}{(\lambda + x^2/2)^{a+1/2}}.$$
I leave it as an exercise to show that this is proportional to a scale-transformed Student's $t$-distribution with $\nu = 2a$ degrees of freedom and scale parameter $1/\sqrt{a\lambda}$.