# 条件分布

1，离散型：设 $$(X,Y)$$ 的联合分布律为 $$P\{X=x_i, Y=y_j\}=p_{ij}$$，则 $$X$$ 在 $$Y=y_j$$ 条件下的条件分布律为

$P\{X=x_i|Y=y_j\}=\frac{P\{X=x_i, Y=y_j\}}{P\{Y=y_j\}}$

$P\{Y=y_j|X=x_i\}=\frac{P\{X=x_i, Y=y_j\}}{P\{X=x_i\}}$

\begin{array}{c|cc|c}Y\backslash X&0&1&P\{Y=y_j\}\\ \hline 0&\frac{1}{6}&\frac{1}{3}&\frac{1}{2}\\ 1&\frac{1}{6}&\frac{1}{3}&\frac{1}{2}\\ \hline P\{X=x_i\}& \frac{1}{3}&\frac{2}{3}&1\end{array}

\begin{align*}&P\{X=0|Y=1\}=\frac{P\{X=0, Y=1\}}{P\{Y=1\}}=\frac{\frac{1}{6}}{\frac{1}{2}}=\frac{1}{3}\\& P\{X=1|Y=1\}=\frac{P\{X=0, Y=1\}}{P\{Y=1\}}=\frac{\frac{1}{3}}{\frac{1}{2}}=\frac{2}{3}\end{align*}

\begin{array}{c|cc}X&0&1\\ \hline P\{X=k|Y=1\}&\frac{1}{3}&\frac{2}{3}\end{array}

（2）同理，

\begin{align*}& P\{Y=0|X=0\}=\frac{P\{X=0, Y=0\}}{P\{X=0\}}=\frac{\frac{1}{6}}{\frac{1}{3}}=\frac{1}{2}\\ &P\{Y=1|X=0\}=\frac{P\{X=0, Y=1\}}{P\{X=0\}}=\frac{\frac{1}{6}}{\frac{1}{3}}=\frac{1}{2}\end{align*}

\begin{array}{c|cc}Y&0&1\\ \hline P\{Y=k|X=0\}&\frac{1}{2}&\frac{1}{2}\end{array}

2，连续型：设 $$(X,Y)$$ 的联合密度为 $$f(x,y)$$ ，对固定的某个 $$y, f_Y(y)\ne 0$$，则 $$X$$ 在 $$Y=y$$ 下的条件密度为

$f_{X|Y=y}(x|y)=\frac{f(x,y)}{f_Y(y)}$

$f(x,y)=\begin{cases}\frac{12}{5}x(2-x-y), &0<x<1,0<y<1\\ 0,&\text{其它}\end{cases}$

\begin{align*}f_Y(y)&=\int_{-\infty}^{\infty}f(x,y)dx=\int_0^1\frac{12}{5}x(2-x-y)dx\\ &=\frac{12}{5}\left(x^2-\frac{x^3}{3}-frac{1}{2}x^2y\right)\Big|_0^1=\frac{12}{5}\left(\frac{2}{3}-\frac{1}{2}y\right)\end{align*}

\begin{align*}f_{X|Y=y}(x|y)&=\frac{f(x,y)}{f_Y(y)}=\frac{\frac{12}{5}x(2-x-y)}{\frac{12}{5}\left(\frac{2}{3}-\frac{1}{2}y\right)}\\ &=\frac{x(2-x-y)}{\frac{2}{3}-\frac{1}{2}y}=\frac{6x(2-x-y)}{4-3y}\end{align*}

\begin{align*}f_{X|Y=y}(x|\frac{1}{2})&=\frac{6x(2-x-\frac{1}{2})}{4-\frac{3}{2}}=\frac{6x(3-2x)}{5}\end{align*}