A linear function has the form $f(x)=aX+b$, where $a$ and $b$ are constants. Let $Y$ be the [[Random Variable]] after this linear transformation. $ Y=aX+b $ ## Discrete Distribution For a discrete [[Random Variable]] $X$, the PMF is first widened by a factor $a$ and then shifted by $b$. $ \begin{align} p(y) &= \mathbf P(Y=y)\\[6pt] &= \mathbf P(Y=aX+b)\\[2pt] &= \mathbf P\big(X=\frac{y-b}{a}\big)\\ &= p_X\big (\frac{y-b}{a}\big ) \end{align} $ **Example:** If $Y=2X+3$, then the PMF is stretched by a factor of $2$ and shifted by $3$. For $y=5$ we set that it equals $x=1$. $ p_Y(5)=p_X\Big(\frac{5-3}{2}\Big)=p_X(1) $ ![[derived-distribution-linear-1.png|center|300]] ![[derived-distribution-linear-3.png|center|300]] ## Continuous Distribution For a continuous r.v. $X$, the density of $Y$ needs to be scaled according to the factor $a$. This is because the [[Probability Density Function|PDF]] is stretched or compressed, but it still needs to sum up to $1$. We could now apply the same equation as in the discrete case.. $ \mathbf P(Y=y) =\mathbf P(aX+b=y) =\mathbf P(X=\frac{y-b}{a}) $ However, since both $\mathbf P(Y=y)=0$ and $\mathbf P(X=x)=0$ at any specific point, this equation is not really informative. Instead we can look at the [[Cumulative Density Function|CDF]], which is always well-defined. There are 3 possible scenarios: **Where $a=0$:** In this scenario the derived distribution of $Y$will collapse to a constant $Y=b$. It is therefore not interesting for our purpose. **Where $a>0$:** $ \begin{align} F_Y(y) &= \mathbf P(Y\leq y) \\[8pt] &= \mathbf P(aX+b \leq y) \\[4pt] &= \mathbf P \Big(X \leq \frac{y-b}{a}\Big)\\[2pt] &=F_X \Big(\frac{y-b}{a}\Big) \end{align} $ **Where $a<0$:** $ \begin{align} F_Y(y) &= \mathbf P(Y\leq y) \tag{1}\\[6pt] &= \mathbf P(aX+b \leq y) \tag{2}\\[2pt] &=\mathbf P\Big(X \ge \frac{y-b}{a} \Big) \tag{3}\\ &=1- \mathbf P\Big(X \leq \frac{y-b}{a}\Big) \tag{4}\\ &=1- F_X\Big(\frac{y-b}{a}\Big) \tag{5} \end{align} $ (3) When multiplying or dividing an inequality by a negative number the inequality sign flips. This is a fundamental property of inequalities, as negative numbers invert the order on the number line. To get to the PDF we need to differentiate the CDF. For this, we need to apply the [[Differentiation Rules#Chain Rule|Chain rule]]. This means we integrate $F_X()$ and $(\frac{y-b}{a})$ separately and multiply the results. **Where $a>0$:** $ \begin{align} F_Y(y) &= F_X(\frac{y-b}{a}) \\[6pt] f_Y(y) &= f_X(\frac{y-b}{a})*\frac{1}{a} \end{align} $ **Where $a<0$:** $ \begin{align} F_Y(y) &= 1-F_X(\frac{y-b}{a}) \\[6pt] f_Y(y) &= -f_X(\frac{y-b}{a})*\frac{1}{a} \end{align} $ Both scenarios lead to the same general formula as the negative $a$ when $a<0$ cancels out the negative $f_X$. Therefore we put $a$ as absolute value to generalize the formulas of both cases. $ f_Y(y)=\frac{1}{\lvert a \rvert} * f_X\Big(\frac{y-b}{a}\Big) $ **Example:** Let $Y=2X+3$. ![[derived-distribution-linear-4.png|center|400]] ## Gaussian Distribution A [[Gaussian Distribution]] has the special property that, a linear transformation of a Gaussian will also be Gaussian. $ \begin{rcases} X \sim \mathcal N(\mu, \sigma^2) \\[4pt] Y=aX+b \end{rcases} Y \sim \mathcal N(a\mu+b, a^2 \sigma^2) $ **Derivation:** The PDF of $X \sim \mathcal N(\mu, \sigma^2)$ looks as follows.. $ f_X(x)=\frac{1}{\sqrt{2\pi}\sigma}* e^{-(x-\mu)^2/2\sigma^2} $ We apply the formula from the [[Linear Functions of Random Variables#Continuous Case|continuous case]] and insert the Gaussian PDF. $ \begin{align} f_Y(y)&=\frac{1}{\lvert a \rvert} * f_X\Big(\frac{y-b}{a}\Big) \tag{1}\\ &=\frac{1}{\lvert a \rvert} * \frac{1}{\sqrt{2\pi}\sigma}* e^{-(\frac{y-b}{a}-\mu)^2/2\sigma^2} \tag{2}\\ &=\frac{1}{\lvert a \rvert} * \frac{1}{\sqrt{2\pi}\sigma}* e^{-(y-b-a\mu)^2/2\sigma^2a^2} \tag{3} \end{align} $ (3) Multiplying the numerator and denominator of the exponent with $a^2$.