# pdf of y=g(x) where g(x) is a discontinuous function

I have:

$f(x) = 0.1\delta(x-2) +0.4\delta(x-1) +{1 \over 4}e^{-|x|}$

$Y=g(x)=0, x\le0$
$g(x)=x^2, 0<x<1$
$g(x)=1, x\gt1$

The task is to find the pdf (density function) of y.

$P(Y=0)=P(X<0)=\int_{-\infty}^0f(x)dx=\int_{-\infty}^0{1 \over 4}e^{x}$
Since the diracs are all zero in the interval and -|x|=x in the interval. thus $f(y)= {1 \over 4}\delta(y)$ is one component of the resulting f(y)

$P(Y=1)=\int_1^{\infty}f(x)dx=\int_1^{\infty}0.1\delta(x-2) +\int_1^{\infty}0.4\delta(x-1)+\int_1^{\infty}{1 \over 4}e^{-x}$
$=0.1+0.4+{1 \over 4}e^{-1}=0.5919698603$
thus $f(y)= (0.5+{1 \over 4}e^{-1})\delta(y-1)$ is one component of the resulting f(y)

finally i evaluate the problem for $0<x<1$ if find fy by the formula:
$f(y)=\Sigma_0^1 {f(xi) \over |g'(x_i)|}$

$g'(x)=2x$
$x_i=y-g(x)$
$x_1=\sqrt y$
$x_2=-\sqrt y$

$f(y)={1 \over {4 |2*-\sqrt y|}}e^{-|-\sqrt y |}+{1 \over {4 |2\sqrt y|}}e^{-|\sqrt y |}$
$={2 \over {4 |2\sqrt y|}}e^{-|\sqrt y |}={1 \over {4 |\sqrt y|}}e^{-|\sqrt y |}$

thus the pdf of y is ${1 \over {4 |\sqrt y|}}e^{-|\sqrt y |}$ for $0<y<1$

evaluating $\int_0^1f(y)dy$ yields:
$-{1 \over 2}e^{-|1|}-(-{1 \over 2}e^{-|0|})=0.31606$

If we add the areas under the full pdf f(y) together, we get an area under the whole pdf that is:
$0.5919698603+0.31606+0.25=1.15$

As one can see this does not add up to one, and i clearly has misunderstood something in the definition of how to calculate Y=g(x).

Edit: The pdf, of y, that i find is:
$f(y)={1 \over {4 |\sqrt y|}}e^{-|\sqrt y |}+(0.5+{1 \over 4}e^{-1})\delta(y-1)+{1 \over 4}\delta(y)$

But the integral $\int_{-\infty}^{\infty}f(y)dy \ne 1$

Since i have checked my calculations several times, i must have misunderstood something about how to find the pdf of y for the given pdf of x, f(x), and the given Y= g(x).

Edit 2: Could it be that the root $x_2=-\sqrt y$ is not valid in the interval so the result $f(y)={1 \over {4 |2*-\sqrt y|}}e^{-|-\sqrt y |}+{1 \over {4 |2\sqrt y|}}e^{-|\sqrt y |}$ should actually be:
$f(y)={1 \over {4 |2\sqrt y|}}e^{-|\sqrt y |}$

-
$f(x)$ is the density of a mixed distribution, a standard Laplace distribution with probability $0.5$ and two points of positive probability. $g(x)$ is the cumulative distribution of a triangular distribution. But I do not see what the question is. Perhaps you are looking for the distribution of $g(X)$ where $X$ has $f(x)$ as its density? –  Henry Feb 19 '12 at 11:31
You are making a sign error when you find $$\int_1^\infty \frac{1}{4}e^{-x}\mathrm dx = -\frac{1}{4}e^{-1}.$$ The integral of a positive function should be positive. –  Dilip Sarwate Feb 19 '12 at 15:54
Think i found the issue, see "Edit2" –  jwmbrg Feb 19 '12 at 16:15

Let $u$ denote any bounded measurable function, then $\mathrm E(u(Y))=\mathrm E(u(g(X))$ hence $$\mathrm E(u(Y))=u(0)\mathrm P(X\leqslant0)+\int_0^1u(x^2)\frac14e^{-x}\mathrm dx+u(1)\mathrm P(X\geqslant1).$$ One computes $$\mathrm P(X\leqslant0)=\int_{-\infty}^0\frac14\mathrm e^x\mathrm dx=\frac14,$$ and $$\mathrm P(X\geqslant1)=0.1+0.4+\int_1^{+\infty}\frac14\mathrm e^{-x}\mathrm dx=0.5+\frac14\mathrm e^{-1}.$$ In the continuous part, the change of variable $y=x^2$, $\mathrm dy=2x\mathrm dx=2\sqrt{y}\mathrm dx$, yields $$\int_0^1u(x^2)\frac14\mathrm e^{-x}\mathrm dx=\int_0^1u(y)\frac14\mathrm e^{-\sqrt{y}}\frac1{2\sqrt{y}}\mathrm dy.$$ Finally, $$\mathrm E(u(Y))=\frac14u(0)+\int_0^1u(y)\frac18\mathrm e^{-\sqrt{y}}\frac1{\sqrt{y}}\mathrm dy+\left(\frac12+\frac14\mathrm e^{-1}\right)u(1),$$ for every bounded measurable $u$ hence the distribution $\mathrm P_Y$ of $Y$ is $$\mathrm P_Y(\mathrm dy)=\frac14\delta_0(\mathrm dy)+\frac18\mathrm e^{-\sqrt{y}}\frac1{\sqrt{y}}[0\lt y\lt1]\mathrm dy+\left(\frac12+\frac14\mathrm e^{-1}\right)\delta_1(\mathrm dy).$$ Sanity check: The mass of the Dirac at $0$ part is $\frac14$, the mass of the continuous part is $\frac14(1-\mathrm e^{-1})$ and the mass of the Dirac at $1$ part is $\frac12+\frac14\mathrm e^{-1}$, hence the total mass is $1$. We happy.