# CDF of a random variable evaluated at a differently distributed random variable

Let $X$ be a random variable on $\mathbb{R}$ and $Y$ another random variable, independent from $X$ and also defined on $\mathbb{R}$. Let $F_X$ be the CDF of $X$. I'm interested in calculating the distribution of $F_X(Y) = \mathbb{P}(X \leq Y \mid Y)$. Is there a general way of calculating this?

We know that if $X$ and $Y$ are continuous and identically distributed, $F_X(Y) \sim Uniform[0, 1]$, but what about in general? Or maybe, if we look at a simplified example:

Let $X \sim N(0,1)$, $Y \sim N(\mu, 1)$, $X$ independent of $Y$, what is the distribution of $F_X(Y)$?

On this particular example, I did some simulations in R programming language and I have a sense that $F_X(Y)$ is Beta distributed, but couldn't find a way to prove it. I also obtained similar results when $X$,$Y$ were Chi-squared, Exponential, or Weibull distributed.

Any help or further literature is greatly appreciated!

• For starters, $F_X(Y)$ takes on values in $(0,1)$ or $(0,1]$ or $[0,1)$ or $[0,1]$ and so it is not too surprising that Beta distributions spring to mind when doing simulations. – Dilip Sarwate Aug 24 '17 at 18:07
• (1) By varying $X$ and $Y$ you can produce literally any distribution on $[0,1]$. (2) It is not the case that $F_X(Y)$ must be uniform when identically distributed: you must assume both $X$ and $Y$ have continuous distributions. (3) The ways of computing $F_X(Y)$ are no different than the methods available to compute any distribution function. Which ones will work depends on how you have specified $F_X$ and $F_Y$. – whuber Aug 24 '17 at 20:40
• Thanks for your feedback! (1) - I agree; (2) True, I edited my question; (3) Yes, and Jarle's answer gave me a push further in deriving the result. – Damjan Aug 24 '17 at 21:14

The cdf of $Z=F_X(Y)$ is \begin{align} F_Z(z) &=P(Z\le z) \\&=P(F_X(Y) \le z) \\&=P(Y \le F_X^{-1}(z)) \\&=F_Y(F_X^{-1}(z)). \end{align} If $F_X$ is not continuous and strictly increasing, for example if $X$ is discrete, then $F_X^{-1}$ is the generalised inverse of $F_X$, that is, $F_X^{-1}(z)=\mathrm{inf}(y \in \mathbb R:F_X(y)\ge z)$, also known as the quantile function of $X$.

In the case that $X$ and $Y$ are both continuous and the support of $Y$ is a subset of the support of $X$, the pdf of $Z$ becomes $$f_Z(z) = \frac d{dz}F_Z(z)=f_Y(F_X^{-1}(z))\frac d{dz}F_X^{-1}(z)=\frac{f_Y(F_X^{-1}(z))}{f_X(F_X^{-1}(z))}. \tag{1}$$ If both $X$ and $Y$ are continuous but $Y$ has larger support than $X$, for example if $X\sim\mathrm{exp}(1)$ and $Y\sim N(1,1)$, then $Z$ has a pdf given by (1) but in addition a point mass of size $P(Y\le 0)=\phi(-1)=0.1586$ in $z=0$.

R code illustrating this:

n <- 1e+4
X <- rexp(n,shape=1,scale=1)
Y <- rnorm(n,mean=1)
Z <- pexp(Y)
hist(Z,prob=TRUE)

• +1 -- but it might be worth pointing out that this derivation implicitly assumes the distributions are continuous (and not just when you differentiate: that assumption sneaks in at the point you refer to $F_X^{-1}$). – whuber Aug 24 '17 at 20:58
• Great, thanks! So, for my example, we get $F_X^{-1} (z) = \sqrt{2} Erf^{-1} (2z-1)$, which is defined for $z \in (0,1)$ (reference: en.wikipedia.org/wiki/Normal_distribution#Quantile_function). Consequently, $F_Z(z) = \frac{1}{2}[1 + Erf[\frac{1}{\sqrt{2}}(\sqrt{2}Erf^{-1}(2z-1)-\mu)]]$, which doesn't seem like a distribution of a Beta distributed variable. Similarly, we can also calculate $f_Z(z)$. – Damjan Aug 24 '17 at 21:28