Salta al contenuto
Note per Studenti Conditional Distributions of Random Variables Report

Conditional Distributions of Random Variables

In questa pagina 3

The basic idea of conditioning is the re-evaluation of the probabilities when new information becomes available in terms of the occurrence of given events. The idea can be extended to random variables: it is of interest to re-evaluate the density, or distribution function, of the random variable when new information becomes available. Discrete and continuous random variables are treated in parallel, pointing out the differences where necessary.

There are at least three different types of events with respect to which the distribution function (or density) of a random variable can be conditioned.

Type 1: the event E⊂ΩE\subset\Omega is not defined in terms of XX

The conditional DF is defined as

FX∣E(x)=P(X≤x∣E).F_{X|E}(x)=P(X\le x\mid E).

In principle FX∣E(x)=P(X≤x∣E)=P([X≤x]∩E)P(E)F_{X|E}(x)=P(X\le x\mid E)=\dfrac{P([X\le x]\cap E)}{P(E)}, but in practice, very often, FX∣E(x)F_{X|E}(x) is part of the data of the problem at hand and it is not computed.

The conditional density, discrete, absolutely continuous or mixed, is defined similarly:

  • discrete: pX∣E(xi)=P(X=xi∣E)p_{X|E}(x_i)=P(X=x_i\mid E) for all xi∈Xx_i\in\mathcal{X};
  • absolutely continuous: fX∣E(x∣E)=ddxFX∣E(x)f_{X|E}(x\mid E)=\dfrac d{dx}F_{X|E}(x) for all x∈Rx\in\mathbb{R}.

Example (urn with coins). An urn contains 22 biased coins with P(H)=p≠12P(H)=p\neq\frac12 and 11 fair coin with P(H)=12P(H)=\frac12. One coin is drawn from the urn; let E=E= "the coin drawn is biased". The random variable XX which models one toss of the coin drawn has conditional density (convince yourself)

pX∣E(x)=px(1−p)1−x,x∈{0,1}(0=Tails, 1=Heads),p_{X|E}(x)=p^x(1-p)^{1-x},\quad x\in\{0,1\}\quad(0=\text{Tails},\ 1=\text{Heads}),

while

pX∣Ec(x)=(12)x(1−12)1−x=12,x∈{0,1}.p_{X|E^c}(x)=\left(\tfrac12\right)^x\left(1-\tfrac12\right)^{1-x}=\tfrac12,\quad x\in\{0,1\}.

By the law of total probability one can also compute the mixture density

pX(x)=pX∣E(x)P(E)+pX∣Ec(x)P(Ec)=23px(1−p)1−x+13⋅12,∀x∈{0,1}.p_X(x)=p_{X|E}(x)P(E)+p_{X|E^c}(x)P(E^c)=\frac23p^x(1-p)^{1-x}+\frac13\cdot\frac12,\quad\forall x\in\{0,1\}.

(P(E)=23P(E)=\frac23 and P(Ec)=13P(E^c)=\frac13: two biased coins out of three.) Mixture densities are an example of application of conditioning for random variables; more on this later.

Type 2: the event is defined in terms of XX itself

E=[X∈B]E=[X\in B] for some BB.

Example (geometric, memoryless). Let X∼Ge(p)X\sim\mathrm{Ge}(p) geometric, with density pX(k)=(1−p)k−1p 1(k−1)p_X(k)=(1-p)^{k-1}p\,\mathbb{1}(k-1). Consider the event E=[X>h]E=[X>h]. The conditional density pX∣E(k)≡pX∣[X>h](k)p_{X|E}(k)\equiv p_{X|[X>h]}(k) is

pX∣E(k)=P([X=k]∩[X>h])P(X>h)={P(X=k)P(X>h)k≥h+1P(∅)P(X>h)k≤h=P(X=k)P(X>h)1(k−h−1)p_{X|E}(k)=\frac{P([X=k]\cap[X>h])}{P(X>h)}=\begin{cases}\dfrac{P(X=k)}{P(X>h)}&k\ge h+1\\[3mm]\dfrac{P(\emptyset)}{P(X>h)}&k\le h\end{cases}=\frac{P(X=k)}{P(X>h)}\mathbb{1}(k-h-1)

=(1−p)k−1p(1−p)h1(k−h−1)=(1−p)k−h−1p 1(k−h−1)=pX(k−h).=\frac{(1-p)^{k-1}p}{(1-p)^h}\mathbb{1}(k-h-1)=(1-p)^{k-h-1}p\,\mathbb{1}(k-h-1)=p_X(k-h).

Remark. This is a consequence of the memoryless property of the geometric law: given X>hX>h, the excess X−hX-h has again the geometric density.

Type 3: the event is defined in terms of another random variable

E=[Y∈B]E=[Y\in B] for some BB, where (X,Y)(X,Y) are jointly distributed according to a known joint DF or density.

Discrete random variables X,YX,Y

Let (X,Y)(X,Y) be jointly distributed according to pXY(xi,yj)p_{XY}(x_i,y_j), (xi,yj)∈X×Y(x_i,y_j)\in\mathcal{X}\times\mathcal{Y} (see Discrete Random VectorsA discrete random vector (X,Y) is described by its joint discrete density p_XY(x_i,y_j) = P(X = x_i, Y = y_j), whose marginals are obtained by summing over the other variable and which gives expectations of any function g(X,Y), including E(XY), covariance and the density of X + Y.Discrete Random Vectors →). The most common conditioning of XX is with respect to the events [Y=yj][Y=y_j], yj∈Yy_j\in\mathcal{Y}. The conditional density is

pX∣Y(xi∣yj)=P(X=xi∣Y=yj)=pXY(xi,yj)pY(yj)=pXY(xi,yj)∑xi′pXY(xi′,yj).p_{X|Y}(x_i\mid y_j)=P(X=x_i\mid Y=y_j)=\frac{p_{XY}(x_i,y_j)}{p_Y(y_j)}=\frac{p_{XY}(x_i,y_j)}{\sum_{x_{i'}}p_{XY}(x_{i'},y_j)}.

Of course it is also possible to define

pY∣X(yj∣xi)=pXY(xi,yj)pX(xi).p_{Y|X}(y_j\mid x_i)=\frac{p_{XY}(x_i,y_j)}{p_X(x_i)}.

As is already well known, pX∣Y(xi∣yj)p_{X|Y}(x_i\mid y_j) is a density over X\mathcal{X} (for each fixed yjy_j) and pY∣X(yj∣xi)p_{Y|X}(y_j\mid x_i) is a density over Y\mathcal{Y}.

Exercise (left by the notes). Compute ∑i,jpX∣Y(xi∣yj)\sum_{i,j}p_{X|Y}(x_i\mid y_j). Hint: for each fixed yjy_j the sum over ii is 11, so the double sum equals the number of values yjy_j (of positive probability).

Remark. In practice the data of a problem are very often pX∣Y(xi∣yj)p_{X|Y}(x_i\mid y_j) and pY(yj)p_Y(y_j), or alternatively pY∣X(yj∣xi)p_{Y|X}(y_j\mid x_i) and pX(xi)p_X(x_i). From the data it is then possible to construct the joint density pXY(xi,yj)p_{XY}(x_i,y_j).

Marginals and Bayes

pX(xi)=∑yjpXY(xi,yj),pY(yj)=∑xipXY(xi,yj),p_X(x_i)=\sum_{y_j}p_{XY}(x_i,y_j),\qquad p_Y(y_j)=\sum_{x_i}p_{XY}(x_i,y_j),

pY∣X(yj∣xi)=pX∣Y(xi∣yj) pY(yj)pX(xi)=pX∣Y(xi∣yj) pY(yj)∑yℓpX∣Y(xi∣yℓ) pY(yℓ)p_{Y|X}(y_j\mid x_i)=\frac{p_{X|Y}(x_i\mid y_j)\,p_Y(y_j)}{p_X(x_i)}=\frac{p_{X|Y}(x_i\mid y_j)\,p_Y(y_j)}{\sum_{y_\ell}p_{X|Y}(x_i\mid y_\ell)\,p_Y(y_\ell)}

(the page writes pX(xi∣yℓ)p_X(x_i\mid y_\ell) in the denominator; it is the conditional density pX∣Yp_{X|Y}, as the numerator shows). The notion of independence, defined through the factorization of the joint density, is in Independent Random VariablesDiscrete random variables X and Y are independent when the joint density factorizes as p_XY = p_X p_Y for all pairs; independence is preserved by functions f(X), g(Y), implies E(XY) = E(X)E(Y) and var(X + Y) = var(X) + var(Y), but uncorrelated does not imply independent.Independent Random Variables →.

Versione ripasso

Idea. Re-evaluate the DF or density of XX when an event is known to occur.

Type 1: EE unrelated to XX. FX∣E(x)=P(X≤x∣E)=P([X≤x]∩E)P(E)F_{X|E}(x)=P(X\le x\mid E)=\dfrac{P([X\le x]\cap E)}{P(E)} (often given as data); pX∣E(xi)=P(X=xi∣E)p_{X|E}(x_i)=P(X=x_i\mid E); fX∣E=ddxFX∣Ef_{X|E}=\frac d{dx}F_{X|E}. Urn (2 biased coins with pp, 1 fair): pX∣E(x)=px(1−p)1−xp_{X|E}(x)=p^x(1-p)^{1-x}, pX∣Ec(x)=12p_{X|E^c}(x)=\frac12, mixture pX(x)=23px(1−p)1−x+13⋅12p_X(x)=\frac23p^x(1-p)^{1-x}+\frac13\cdot\frac12.

Type 2: E=[X∈B]E=[X\in B]. Geometric X∼Ge(p)X\sim\mathrm{Ge}(p), E=[X>h]E=[X>h]: pX∣E(k)=P(X=k)P(X>h)1(k−h−1)=(1−p)k−h−1p 1(k−h−1)=pX(k−h)p_{X|E}(k)=\dfrac{P(X=k)}{P(X>h)}\mathbb{1}(k-h-1)=(1-p)^{k-h-1}p\,\mathbb{1}(k-h-1)=p_X(k-h) (memoryless; P(X>h)=(1−p)hP(X>h)=(1-p)^h).

Type 3: E=[Y=yj]E=[Y=y_j] (discrete). pX∣Y(xi∣yj)=pXY(xi,yj)pY(yj),pY∣X(yj∣xi)=pXY(xi,yj)pX(xi);p_{X|Y}(x_i\mid y_j)=\frac{p_{XY}(x_i,y_j)}{p_Y(y_j)},\qquad p_{Y|X}(y_j\mid x_i)=\frac{p_{XY}(x_i,y_j)}{p_X(x_i)}; each is a density (sums to 11 over its own variable). Joint from data: pXY=pX∣Y pY=pY∣X pXp_{XY}=p_{X|Y}\,p_Y=p_{Y|X}\,p_X. Bayes: pY∣X(yj∣xi)=pX∣Y(xi∣yj)pY(yj)∑yℓpX∣Y(xi∣yℓ)pY(yℓ)p_{Y|X}(y_j\mid x_i)=\dfrac{p_{X|Y}(x_i\mid y_j)p_Y(y_j)}{\sum_{y_\ell}p_{X|Y}(x_i\mid y_\ell)p_Y(y_\ell)}.

Typical mistakes. Dividing by the wrong marginal (pYp_Y for pX∣Yp_{X|Y}, pXp_X for pY∣Xp_{Y|X}); forgetting the indicator 1(k−h−1)\mathbb{1}(k-h-1) (the conditional density vanishes for k≤hk\le h); weighting a mixture with the wrong P(E)P(E), P(Ec)P(E^c).