# 機率HW9
## 110590064 資工二 劉韶軒
## Problem 1
### 題目
>Let the joint probabilty mass fuction of discreate random variable X and Ybe given by
>p(x,y)
>=c(x+y) if x=1,2,3,y=1,2
>=0 otherwise
>(a) the value of the constant c
>(b) the marginal probabilty mass function of X,Y
>(c) P(x>=2|Y=1)
>(d)E(X) and E(Y)
### 解答
#### (a)
$∑∑p(x,y) = 1$
$p(1,1) + p(1,2) + p(2,1) + p(2,2) + p(3,1) + p(3,2) = 1$
$c(1+1) + c(1+2) + c(2+1) + c(2+2) + c(3+1) + c(3+2) = 1$
$=2c+3c+3c+4c+4c+5c = 1$
$=21c=1;c=\frac{1}{21}$
#### (b)
$pX(x) = Σ p(x,y)$
$pX(1) = p(1,1) + p(1,2) = c(1+1) + c(1+2) = 2c + 3c = 5c$
$pX(2) = p(2,1) + p(2,2) = c(2+1) + c(2+2) = 3c + 4c = 7c$
$pX(3) = p(3,1) + p(3,2) = c(3+1) + c(3+2) = 4c + 5c = 9c$
$pX(x) = 5c,當 x=1$
$pX(x) = 7c,當 x=2$
$pX(x) = 9c,當 x=3$
$pY(y) = Σ p(x,y)$
$pY(1) = p(1,1) + p(2,1) + p(3,1) = c(1+1) + c(2+1) + c(3+1) = 2c + 3c + 4c = 9c$
$pY(2) = p(1,2) + p(2,2) + p(3,2) = c(1+2) + c(2+2) + c(3+2) = 3c + 4c + 5c = 12c$
$pY(y) = 9c,當 y=1$
$pY(y) = 12c,當 y=2$
#### (c)
$p(x>=2|Y=1) = \frac{p(x>=2,Y=1)}{ p(Y=1)}$
$p(x>=2,Y=1) = p(2,1) + p(3,1) = c(2+1) + c(3+1) = 3c + 4c = 7c$
$p(Y=1) = 9c$
$p(x>=2|Y=1) = \frac{7c}{9c} = \frac{7}{9}$
#### (d)
$E(X) = Σ x * pX(x)$
$E(X) = 1 * pX(1) + 2 * pX(2) + 3 * pX(3)=46c$
$E(Y) = Σ x * pY(y)$
$E(Y) = 1 * pY(1) + 2 * pY(2) =33c$
帶入$c=\frac{1}{21}$
$E(X)=\frac{46}{21}$
$E(Y)=\frac{33}{21}$
## Problem 2
### 題目
> Two fair dice are rolled. The sum of the outcome is denoted by X and the absolute value of the difference by Y. Calculate the joint probability mass function of X and Y and the marginal probability mass functions of X and Y.
### 解答
$X=2~P(X=2,Y=0)=P(A=1,B=1)=\frac{1}{36}$
$X=3~P(X=3,Y=1)=P(A=1,B=2)+P(A=2,B=1)=\frac{2}{36}$
$X=4$
$~P(X=4,Y=0)=P(A=2,B=2)+P(A=3,B=1)=\frac{2}{36}$
$~P(X=4,Y=1)=P(A=3,B=1)+P(A=4,B=0)=\frac{2}{36}$
$X=5$
$~P(X=5,Y=1)=P(A=2,B=3)+P(A=3,B=2)=\frac{2}{36}$
$~P(X=5,Y=3)=P(A=1,B=4)+P(A=4,B=1)=\frac{2}{36}$
$X=6$
$~P(X=6,Y=0)=P(A=3,B=3)=\frac{1}{36}$
$~P(X=6,Y=2)=P(A=2,B=4)+P(A=4,B=2)=\frac{2}{36}$
$~P(X=6,Y=4)=P(A=1,B=5)+P(A=5,B=1)=\frac{2}{36}$
$X=7$
$~P(X=7,Y=1)=P(A=3,B=4)+P(A=4,B=3)=\frac{2}{36}$
$~P(X=7,Y=3)=P(A=2,B=5)+P(A=5,B=2)=\frac{2}{36}$
$~P(X=7,Y=5)=P(A=1,B=6)+P(A=6,B=1)=\frac{2}{36}$
$X=8$
$~P(X=8,Y=0)=P(A=4,B=4)=\frac{1}{36}$
$~P(X=8,Y=2)=P(A=3,B=5)+P(A=5,B=3)=\frac{2}{36}$
$~P(X=8,Y=4)=P(A=2,B=6)+P(A=6,B=2)=\frac{2}{36}$
$~P(X=8,Y=6)=P(A=1,B=7)+P(A=7,B=1)=\frac{2}{36}$
$X=9$
$~P(X=9,Y=1)=P(A=4,B=5)+P(A=5,B=4)=\frac{2}{36}$
$~P(X=9,Y=3)=P(A=3,B=6)+P(A=6,B=3)=\frac{2}{36}$
$~P(X=9,Y=5)=P(A=2,B=7)+P(A=7,B=2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)=\frac{6}{36}$
$P(Y=1)=\frac{10}{36}$
$P(Y=2)=\frac{8}{36}$
$P(Y=3)=\frac{8}{36}$
$P(Y=4)=\frac{8}{36}$
$P(Y=5)=\frac{6}{36}$
$P(Y=6)=\frac{6}{36}$
$P(Y=7)=\frac{4}{36}$
$P(Y=8)=\frac{4}{36}$
$P(Y=9)=\frac{2}{36}$
$P(Y=10)=\frac{2}{36}$
## Problem 3
### 題目
> Let the joint probabilty density fuction of random variable X and Ybe given by
> f(x,y) =2 if 0<=y<=x<=1 > = 0 otherwise
> (a) Calculate the marginal probability density duction of X and respintivelty
> (b) Find(X) and E(Y)
> ( c) Calcuate P(x<$\frac{1}{2}$),P(X<2Y),and P(X=Y)
> (d)Are X and Y independent? Why or why not?
> (e) $f_{X|Y}(x|y)$
### 解答
#### a
$f_X(x) = ∫_0^1 f(x,y) dy = ∫\_0^x 2 dy = 2x,0 <= x <= 1$
$f_Y(y) = ∫_y^1 f(x,y) dx = ∫\_y^1 2 dx = 2(1-y),0 <= y <= 1$
#### b
$E(X)=∫_0^1{x*f_X(x)}dx=\frac{2}{3}$
$E(Y)=∫_0^1{x*f_Y(u)}dy=\frac{1}{3}$
#### c
$P(x<1/2)=∫_0^{\frac{1}{2}}f_X(x)dx=\frac{1}{4}$
$P(X<2Y)=∫_0^{1}∫_0^{2y}f(x,y)dxdy=2$
$P(X<2Y)=∫_0^{1}f(x,x)dxd=2$
#### d
不互相獨立
再給特定Y條件下,X的取直受到Y影響,如P(X<2Y)
$f_{X|Y}(x|y) = \frac{f(x,y)}{f\_Y(y)} = \frac{2}{2(1-y)} = \frac{1}{1-y}若0 <= y <= x <= 1$
$f\_{X|Y}(x|y) = 0$,
## Problem 4
### 題目
>Let the joint probabilty mass fuction of random variable X and Ybe given by
>p(x,y)
>=$\frac{1}{7}x^2$ if (x,y)==(1,1),(1,2),(2,1)
>=0 otherwise
>Are X and Y indenpendent? Why or why not
### 解答
PMF of X:
$P(X = 1) = p(1,1) + p(1,2) = \frac{1}{7}1^2 + \frac{1}{7}1^2 = \frac{2}{7}$
$P(X = 2) = p(2,1) = \frac{1}{7}(2^2) = \frac{4}{7}$
Marginal PMF of Y:
$P(Y = 1) = p(1,1) + p(2,1) = \frac{1}{7}(1^2) +\frac{1}{7}(2^2) = \frac{5}{7}$
$P(Y = 2) = p(1,2) = \frac{1}{7}(1^2) = \frac{1}{7}$
$P(X = x) * P(Y = y) = \frac{}{7} * \frac{5}{7} = 10/49$
$P(X,Y) ≠ P(X) * P(Y)$
$P(1,1) = \frac{1}{7} ≠ \frac{10}{49}.$
X and Y are not independent because the joint probability mass function cannot be factored into the product of their individual probability mass functions.
## Problem 5
### 題目
>Let the joint probabilty density fuction of random variable X and Ybe given by
>p(x,y)
>=$2e^{-(x+2y)}$ if x>=0 y>=0
>=0 otherwise
>find E((X^2)Y)
### 解答
$E((X^2)Y) = ∫∫ (x^2)y * p(x,y) dx dy$
$E((X^2)Y) = ∫∫ (x^2)y * 2e^{-(x+2y)} dx dy$
$E((X^2)Y) = ∫∫ (2x^2)y * e^{-(x+2y)} dx dy$
$E((X^2)Y) = ∫_0^∞∫_0^∞ (2x^2)y * e^{-(x+2y)} dx dy$
$E((X^2)Y) = ∫_0^∞ (y * e^{-2y}) ∫_0^∞ (2x^2 * e^{-x}) dx dy$
$E((X^2)Y) = ∫_0^∞ (y * e^{-2y}) * Γ(3) dy$
$Γ(3)=2$
$A: \frac{3*\pi}{2}$
## Problem 6
### 題目
>Let the joint probabilty mass fuction of discreate random variable X and Ybe given by
>p(x,y)
>=$\frac{1}{25}{x^2+y^2}$ if x=1,2 y=0,1,2
>=0 otherwise
>find p_{x|y}(x|y),P(X=2| Y=1 ),and E(X|Y=1)
### 解答
$P(Y=0) = p(1,0) + p(2,0) = \frac{1}{25}(1^2+0^2) + \frac{1}{25}(2^2+0^2) = \frac{1}{25} + \frac{4}{25} = \frac{5}{25} = \frac{1}{5}$
$P(Y=1) = p(1,1) + p(2,1) = \frac{1}{25}(1^2+1^2) + \frac{1}{25}(2^2+1^2) = \frac{2}{25} + \frac{5}{25} = \frac{7}{25}$
$P(Y=2) = p(1,2) + p(2,2) = \frac{1}{25}(1^2+2^2) + \frac{1}{25}(2^2+2^2) = \frac{5}{25} + \frac{8}{25} = \frac{13}{25}$
$P(X=1|Y=0) = \frac{p(1,0)}{P(Y=0)} = \frac{\frac{1}{25}(1^2+0^2)}{\frac{1}{5}} = \frac{\frac{1}{25}}{\frac{1}{5}} = \frac{1}{5}$
$P(X=2|Y=0) = \frac{p(2,0)}{P(Y=0)} = \frac{\frac{1}{25}(2^2+0^2)}{\frac{1}{5}} = \frac{\frac{4}{25}}{\frac{1}{5}} = \frac{4}{5}$
$P(X=1|Y=1) = \frac{p(1,1)}{P(Y=1)} = \frac{\frac{1}{25}(1^2+1^2)}{\frac{7}{25}} = \frac{\frac{2}{25}}{\frac{7}{25}} = \frac{2}{7}$
$P(X=2|Y=1) = \frac{p(2,1)}{P(Y=1)} = \frac{\frac{1}{25}(2^2+1^2)}{\frac{7}{25}} = \frac{\frac{5}{25}}{\frac{7}{25}} = \frac{5}{7}$
$P(X=1|Y=2) = \frac{p(1,2)}{P(Y=2)} = \frac{\frac{1}{25}(1^2+2^2)}{\frac{13}{25}} = \frac{\frac{5}{25}}{\frac{13}{25}} = \frac{5}{13}$
$P(X=2|Y=2) = \frac{p(2,2)}{P(Y=2)} = \frac{\frac{1}{25}(2^2+2^2)}{\frac{13}{25}} = \frac{\frac{8}{25}}{\frac{13}{25}} = \frac{8}{13}$
$P(X=2|Y=1) = \frac{5}{7}$
$E(X|Y=1) = ∑x (x * P(X=x|Y=1)) = 1 * P(X=1|Y=1) + 2 * P(X=2|Y=1) = 1 * \frac{2}{7} + 2 * (5/7) =\frac{2}{7} + \frac{10}{7} = \frac{12}{7}$
## Problem 7
### 題目
> A Point(X,Y) is elected randomly from the triangle with vertices (0,0)(1,0)
> (a) Find The joint probablity density function of X and Y
> (b) Calculate f_{x|y}(x|y)
> (c) Evaluate E(X|Y=y)
### 解答
$f(x,y)=\int\_0^1\int\_0^{-x+1}cdydx =c\int\_0^1(-x+1)dx =c(-\frac{1}{2}x^2+x)|\_0^1 =c(-\frac{1}{2}+1)=$
$\frac{c}{2}=1 \therefore c=2 f(x,y)=\begin{cases}2\quad,0\le x\le 1,y\le-x+1\\0\quad,O.W.\end{cases} f_{X|Y}(x|y)=\dfrac{f(x,y)}{f\_Y(y)}$
$=\begin{cases}\frac{2}{-2y+2}\quad,0\le x\le 1, y\le -x+1\\0\quad,O.W.\end{cases} =\begin{cases}\frac{1}{-y+1}\quad,0\le x\le 1, y\le -x+1\\0\quad,O.W.\end{cases}$
$E(X|Y=y)=\int\_{-\infty}^{\infty}xf_{X|Y}(x|y)dx =\int\_0^1x\cdot\frac{1}{-y+1}dx =\frac{1}{-y+1}\cdot\frac{1}{2}(x^2)|\_0^1 =\frac{1}{-2y+2}$