Salta al contenuto
Note per Studenti Functions of Random Variables and LOTUS Report

Functions of Random Variables and LOTUS

Functions of r.v.'s

R.v.'s are functions, therefore it is possible to operate on r.v.'s exactly like one operates on functions. In particular it is possible to consider a function of a function. Specifically, if X:Ω→R,g:R→R,X : \Omega \to \mathbb{R}, \qquad g : \mathbb{R}\to\mathbb{R}, then it is possible to consider the composition of the maps g∘X:Ω→Rg \circ X : \Omega \to \mathbb{R}, defined as Y:Ω→R,ω↦g(X(ω)).Y : \Omega\to\mathbb{R}, \qquad \omega \mapsto g(X(\omega)).

If XX is a discrete r.v. then X=X(Ω)\mathcal{X} = X(\Omega) is a discrete set and Y=g(X)\mathcal{Y} = g(\mathcal{X}) is certainly discrete, since ∣Y∣=∣g(X)∣≤∣X∣|\mathcal{Y}| = |g(\mathcal{X})| \le |\mathcal{X}|. Moreover Y−1({yk})=X−1(g−1({yk}))=⋃xk∈g−1(yk)X−1({xk})∈F,Y^{-1}(\{y_k\}) = X^{-1}\big(g^{-1}(\{y_k\})\big) = \bigcup_{x_k\in g^{-1}(y_k)}X^{-1}(\{x_k\}) \in \mathcal{F}, since ∣g−1(yk)∣≤∣X∣|g^{-1}(y_k)| \le |\mathcal{X}| (a countable union of events of F\mathcal{F}). Conclusion: YY is a discrete r.v.

Examples. If XX is a r.v. and g(x)=x2g(x) = x^2 then Y=g(X)=X2Y = g(X) = X^2 is a function of the r.v. XX. One could consider other functions like X3X^3, X\sqrt X, cos⁡(X)\cos(X), etc.

Problem. Determine the complete probabilistic description of Y=g(X)Y = g(X), i.e. the alphabet Y\mathcal{Y} and the discrete density pY(yk)p_Y(y_k), yk∈Yy_k \in \mathcal{Y}, or alternatively the DF FY(y)F_Y(y), in terms of the probabilistic description of XX, i.e. X\mathcal{X} and pX(xk)p_X(x_k) or FX(x)F_X(x).

Example. Ω={00,01,10,11}\Omega = \{00, 01, 10, 11\} with PP equiprobable. Let X:Ω→R,ω=(b1,b2)↦X(ω)=2(b1+b2)−1,g:R→R,x↦x2.X : \Omega\to\mathbb{R},\quad \omega = (b_1,b_2)\mapsto X(\omega) = 2(b_1+b_2) - 1, \qquad g : \mathbb{R}\to\mathbb{R},\quad x\mapsto x^2. Then XX sends 00↦−100 \mapsto -1, 01,10↦101, 10 \mapsto 1, 11↦311\mapsto 3, and Y=X2Y = X^2 sends −1↦1-1\mapsto1, 1↦11\mapsto1, 3↦93\mapsto9. So Y={1,9}\mathcal{Y} = \{1, 9\} and pY(9)=pX(3)=14,pY(1)=pX(1)+pX(−1)=24+14=34.p_Y(9) = p_X(3) = \tfrac14, \qquad p_Y(1) = p_X(1) + p_X(-1) = \tfrac24 + \tfrac14 = \tfrac34. (Two different values of XX are merged into the value 11 of YY, so their probabilities add.)

Lemma. Let Y=g(X)Y = g(X) where X∼pX(xk)X\sim p_X(x_k), xk∈Xx_k\in\mathcal{X}. Then Y∼pY(yℓ)Y \sim p_Y(y_\ell), yℓ∈Yy_\ell\in\mathcal{Y}, where Y=g(X)\mathcal{Y} = g(\mathcal{X}); moreover pY(yℓ)=∑xkg(xk)=yℓpX(xk).p_Y(y_\ell) = \sum_{\substack{x_k\\ g(x_k) = y_\ell}}p_X(x_k). Proof. [Y=yℓ]=⋃xk: g(xk)=yℓ[X=xk][Y = y_\ell] = \bigcup_{x_k:\ g(x_k) = y_\ell}[X = x_k] (a disjoint union), therefore pY(yℓ)=P([Y=yℓ])=∑xk: g(xk)=yℓpX(xk).□p_Y(y_\ell) = P([Y=y_\ell]) = \sum_{x_k:\ g(x_k)=y_\ell}p_X(x_k). \quad\square

The LOTUS

The LOTUS (law of the unconscious statistician) is a classic result on the computation of the expected value of a function of r.v.'s. It is mathematically identical to the fundamental theorem of expectation (see Expected ValueThe expected value E(X) is the sum of the values of a discrete random variable weighted by their probabilities; it is linear, lies between the smallest and the largest value, and equals the barycenter of the density.Expected Value →) but, contrary to the fundamental theorem, it is extremely useful in practice.

Lemma (LOTUS). Let Y=g(X)Y = g(X) where X∼pX(xk)X\sim p_X(x_k), xk∈Xx_k\in\mathcal{X}. Then E(Y)=E(g(X))=∑xk∈Xg(xk) pX(xk).E(Y) = E(g(X)) = \sum_{x_k\in\mathcal{X}}g(x_k)\,p_X(x_k).

Remark. The practical value of the LOTUS is that it allows the computation of E(Y)E(Y) without the need to first compute pY(yℓ)p_Y(y_\ell), yℓ∈Yy_\ell\in\mathcal{Y}.

Proof. Recall the expression of pY(yℓ)p_Y(y_\ell) in terms of pX(xk)p_X(x_k): E(Y)=∑yℓ∈Yyℓ pY(yℓ)=∑yℓ∈Yyℓ[∑xk: g(xk)=yℓpX(xk)]=∑yℓ∈Y ∑xk: g(xk)=yℓg(xk) pX(xk)=∑xk∈Xg(xk) pX(xk)=E(g(X)).E(Y) = \sum_{y_\ell\in\mathcal{Y}}y_\ell\,p_Y(y_\ell) = \sum_{y_\ell\in\mathcal{Y}}y_\ell\Big[\sum_{x_k:\ g(x_k)=y_\ell}p_X(x_k)\Big] = \sum_{y_\ell\in\mathcal{Y}}\ \sum_{x_k:\ g(x_k)=y_\ell}g(x_k)\,p_X(x_k) = \sum_{x_k\in\mathcal{X}}g(x_k)\,p_X(x_k) = E(g(X)). In the third step yℓy_\ell is replaced by g(xk)g(x_k) (equal on the inner sum); in the fourth the double sum over yℓy_\ell and over the xkx_k in its preimage runs once over every xk∈Xx_k\in\mathcal{X}. □\square

Example. X∼U({−1,0,1})X \sim \mathcal{U}(\{-1, 0, 1\}), so pX(−1)=pX(0)=pX(1)=13p_X(-1) = p_X(0) = p_X(1) = \frac13, and Y=X2Y = X^2. By the LOTUS, E(Y)=E(X2)=∑xk∈Xg(xk)pX(xk)=(−1)213+0213+1213=23.E(Y) = E(X^2) = \sum_{x_k\in\mathcal{X}}g(x_k)p_X(x_k) = (-1)^2\tfrac13 + 0^2\tfrac13 + 1^2\tfrac13 = \tfrac23. Alternatively one can first compute pY(yℓ)p_Y(y_\ell). The alphabet of YY is Y={0,1}\mathcal{Y} = \{0,1\} and pY(1)=∑g(xk)=1pX(xk)=pX(−1)+pX(1)=23,pY(0)=pX(0)=13.p_Y(1) = \sum_{g(x_k)=1}p_X(x_k) = p_X(-1) + p_X(1) = \tfrac23, \qquad p_Y(0) = p_X(0) = \tfrac13. Therefore Y∼b(23)Y\sim b(\frac23) and E(Y)=23E(Y) = \frac23, the same value.

The LOTUS is the tool used to compute the variance, see VarianceThe variance is the expected squared deviation from the expected value and measures how spread out a random variable is; it is non-negative, zero only for constants, scales with the square of a multiplier, ignores shifts, and equals E(X^2) minus the square of E(X).Variance →. See also Functions of a Random VariableTo find the distribution of Y = g(X) one computes the distribution function of Y first (always works, also for mixed results) or, for piecewise invertible g and absolutely continuous X, uses the density formula with the sum of f_X(a) divided by the absolute value of g'(a) over the preimages.Functions of a Random Variable →.

Versione ripasso

  • If XX is a discrete r.v. and g:R→Rg:\mathbb{R}\to\mathbb{R}, then Y=g(X)=g∘XY=g(X)=g\circ X is a discrete r.v. with alphabet Y=g(X)\mathcal{Y}=g(\mathcal{X}), ∣Y∣≤∣X∣|\mathcal{Y}|\le|\mathcal{X}|, and Y−1({y})=⋃xk∈g−1(y)X−1({xk})∈FY^{-1}(\{y\})=\bigcup_{x_k\in g^{-1}(y)}X^{-1}(\{x_k\})\in\mathcal{F}.
  • Density of YY: pY(yℓ)=∑xk: g(xk)=yℓpX(xk)p_Y(y_\ell)=\sum_{x_k:\ g(x_k)=y_\ell}p_X(x_k) (since [Y=yℓ]=⋃g(xk)=yℓ[X=xk][Y=y_\ell]=\bigcup_{g(x_k)=y_\ell}[X=x_k], disjoint).
  • Example: X=2(b1+b2)−1X=2(b_1+b_2)-1 on equiprobable {0,1}2\{0,1\}^2, Y=X2Y=X^2: pY(9)=14p_Y(9)=\frac14, pY(1)=34p_Y(1)=\frac34.
  • LOTUS: E(g(X))=∑xk∈Xg(xk) pX(xk)E(g(X))=\sum_{x_k\in\mathcal{X}}g(x_k)\,p_X(x_k), with no need to find pYp_Y. Proof: E(Y)=∑ℓyℓ∑g(xk)=yℓpX(xk)=∑xkg(xk)pX(xk)E(Y)=\sum_\ell y_\ell\sum_{g(x_k)=y_\ell}p_X(x_k)=\sum_{x_k}g(x_k)p_X(x_k).
  • Example: X∼U({−1,0,1})X\sim\mathcal{U}(\{-1,0,1\}), Y=X2Y=X^2: E(Y)=23E(Y)=\frac23; also Y∼b(23)Y\sim b(\frac23).
  • Typical mistake: E(g(X))≠g(E(X))E(g(X))\ne g(E(X)) in general (e.g. E(X2)=23E(X^2)=\frac23 but E(X)=0E(X)=0 in the example); and forgetting to add the probabilities of the xkx_k that gg maps to the same value.

Teoria collegata