# Rectifier function of random variable

Let $X$ be a random variable with distribution $F_X$ and density $f_X$. Define $$g(x) = \left\{ \begin{array}{lr} x & : x \ge 0\\ 0 & : x < 0 \end{array} \right\}$$

and let $Y=g(X)$. What is the PDF of $Y$?

My approach: via CDF

$$F_Y(y) = \Pr(Y\le y) = \Pr(g(X)\le y) = \Pr(X\le y) = F_X(y), \ y\ge 0$$

After taking the derivative,

$$f_Y(y) = f_X(y), \ y \ge 0$$

This seems to be incorrect because $f_Y(y)$ is not a PDF (integral is not equal to one).

I know that it probably has to do something with the fact that all $x\lt 0$ are mapped onto $y=0$.

I just don't know how I can incorporate this in a constructive way.

• Although you define $g$ specifically, you replace it with a different definition in your calculations: that's where things go wrong. Regardless, there's a fundamental problem with this question: if $X$ has any chance of being negative, then $Y$ does not have a PDF. Also, why do you keep writing "$y=0\ldots 1$"? That isn't part of any explicit definition or assumption. – whuber Jun 24 '14 at 19:15
• @whuber Good you noticed, that was an error in my notes. Isn't there a way to do something with dirac delta perhaps? – tgoossens Jun 24 '14 at 19:17
• Yes, there is, provided you accept such generalized functions as being acceptable PDFs. In your newly edited version I see no errors: your calculation simply is incomplete. What value would you give to $F_Y$ for negative arguments? – whuber Jun 24 '14 at 19:21
• @whuber Using intuition. $F_Y(y) = F_X(0) Heaviside(y) + (F_X(y)-F_X(0))$. This would give $f_Y (y) = F_X(0)\delta(y) + f_X(y)$. However, I have learned that my intuition is often wrong in this topic. – tgoossens Jun 24 '14 at 19:26

Let's assume that $X$ is a continuous random variable. Then, around variables like $Y$ there are two possible confusions related to terminology:

$Y$ is a censored version of $X$ (and sometimes people confuse "censoring" with "truncating"). Also, $Y$ has a mixed distribution (and sometimes people confuse "mixed" distributions with "mixture" distributions).

$Y$ is a censored version of $X$ because a) we observe only non-negative values and b) when we observe $0$ we only know that the corresponding realization of $X$ was $x\leq 0$, i.e. we learn only that $X$ fell in an interval, not its specific value. This also creates the mixed distribution, i.e. a distribution that has a discrete part and a continuous part:

At value $0$, non-zero probability mass concentrates, equal to $P(X\leq 0)$. For $X>0$ we have $Y=X$. So the CDF of Y is

$$F_Y(y) = \left\{ \begin{array}{lr} F_X(y)& : y > 0\\ F_X(0) & : y = 0\\ 0 & \text{elsewhere} \end{array} \right\}$$

and $\lim_{y\rightarrow \infty}F_Y(y)=1$.

As for its probability -mass function? - density function? -well, see the illuminating and educative comments below on the matter, as well as ways to express it in one row. Let's say we have a point where non-zero probability mass concentrates, $P(Y=0) = P(X \leq 0)<1$, while for $y>0$ we have a continuous function $f_X(y)$ that does satisfy $\int_{0}^{\infty}f_X(y)dy = 1- P(X \leq 0)$ , while this entity is $0$ everywhere else. So in all, it sums up to unity.

• I was unfamiliar with the concept of mixed distributions. This helped me a lot and gives a constructive way of deriving the PDF. Thanks – tgoossens Jun 24 '14 at 19:48
• (1) To be complete, you need to stipulate the values of $F_Y$ and $f_y$ for negative arguments. (2) Exactly how would you use an indicator to write $f_Y$? – whuber Jun 24 '14 at 19:55
• Normally I would not insist on the point about covering the case $y\lt 0$, Alecos, but this is precisely the issue that was causing the OP grief, so I thought that dealing with it explicitly would be helpful in this instance. As far as the indicator goes, your proposal doesn't work (even after replacing the "$Y$" by "$y$" in the formula so it makes sense). In order to use such notation you first have to expand the concept of a PDF to cover discrete measures, so you might as well write $f_Y$ explicitly as a measure, as in $$f_X(y)I(y\ge 0)dy+F_X(0)d\delta_0$$ where $\delta_0(A)=I(0\in A).$ – whuber Jun 24 '14 at 21:17
• The CDF is discontinuous at $0$ and so not even giving a hint about this (as in earlier versions of this answer) was certainly not a good idea, as whuber pointed out. While this has been corrected, the pdf is still incorrect. The value of $f_Y$ at $0$ is not $P\{X \leq 0\}$. – Dilip Sarwate Jun 25 '14 at 10:59
• Yes, $P(Y=0)=P(X\leq 0)$ but that is not the value of the density function of $Y$ at $0$. Suppose we are given that $$f_Y(y) = \begin{cases}0.9,&0<y<1,\\0.1,&y=0,\\0.1,&y=1,\\0.1,&y=2.\end{cases}$$ Since the value of a density function at one point has no effect on probability calculations (in fact, two density functions are regarded as equivalent if they differ only on a set of measure $0$), how can we tell if the probability mass is at $0$ or $1$ or at $2$? – Dilip Sarwate Jun 25 '14 at 11:51