# PMF and independence with two discrete random variables?

Each of n people (whom we label 1, 2, . . . , n) are randomly and independently assigned a number from the set {1, 2, 3, . . . , 365} according to the uniform distribution. We will call this number their birthday.
(1) Describe a sample space Ω for this scenario.
Let j and k be distinct labels (between 1 and n) and let $$A_{jk}$$ denote the event that the corresponding people share a birthday. Let $$X_{jk}$$ denote the indicator random variable associated to $$A_{jk}$$.
(2) Write $$A_{12}$$ as a subset of Ω.
(3) Tabulate the joint PMF for $$X_{12}$$ and $$X_{13}$$. Compute the PMF for the product $$X_{12}X_{13}$$.
(4) Tabulate the joint PMF for $$X_{12}$$ and $$X_{34}$$. Compute the PMF for the product $$X_{12}X_{34}$$.
(5) Are $$A_{12}$$ and $$A_{34}$$ independent? Are they independent conditioned on $$A_{13}$$?
(6) Are $$A_{12}$$ and $$A_{13}$$ independent? Are they independent conditioned on $$A_{23}$$?
(7) Compute the expected number of pairs of people who share a birthday (hint:write this number as a sum of $$X_{jk}$$’s).
(8) Compute the second moment and variance of the number of pairs of people who share a birthday

My solutions:
(1) Ω = {1, 2, ..., 365}$$^n$$

(2) $$A_{12}$$ = {(1,1), (2,2), ... (365,365)} * {1, 2, ..., 365}$$^{n-2}$$

(3) $$P(A_{12}$$) = $$365$$ * $$365^{n-2}$$ / $$365^n$$ = $$1/365$$
$$P(X_{12} = 1$$) = $$P(X_{13} = 1$$) = $$1/365$$
$$P(X_{12} = 0$$) = $$P(X_{13} = 0$$) = $$364/365$$

$$X_{12}X_{13}$$ = 1 when $$X_{12}=1$$, $$X_{13}=1$$ else $$X_{12}X_{13}=0$$.
$$P(X_{12}X_{13}=1)$$ = $$1/365^2$$
$$P(X_{12}X_{13}=0)$$ = $$(365^2 - 1) / 365^2$$

(4)

$$P(X_{12}X_{34}=1)$$ = $$1/365^2$$
$$P(X_{12}X_{34}=0)$$ = $$(365^2 - 1) / 365^2$$

(5) They are independent because $$P(X_{12}=i, X_{34}=j)$$ = $$P(X_{12}=i)$$ $$P(X_{34}=j)$$ for i,j in {0,1}.

(6) They are independent because of the same logic as in (5)

I'm not sure how to calculate if they're independent conditioned on another event for parts (5) and (6). Also do not know how to do parts (7) and (8).
Any help is appreciated!

In (5), they're conditionally independent especially because the relationship between 1-2 and 3-4 doesn't depend on 1-3, i.e. $$P(X_{12},X_{34}|X_{13})=P(X_{12},X_{34})=P(X_{12})P(X_{34})=P(X_{12}|X_{13})P(X_{34}|X_{13})$$ Informally, let $$1$$ be me, and $$2$$ be you; if I'm born in the same day with a total stranger (i.e. $$3$$), that stranger's probability of being born on the same day or not with another total stranger is irrelevant to us, making $$X_{34}$$ and $$X_{12}$$ independent given $$X_{13}$$. Formally, you can again calculate the joint PMF by counting the elements of the sample space, as you did for unconditional cases.
In (6), they're not independent, because if $$2-3$$ aren't born on the same day, person $$1$$ cannot be born on the same day with both $$2,3$$, i.e. $$P(A_{12}\cap A_{13}|A_{23}')=0\neq P(A_{12}|A_{23}')P(A_{13}|A_{23}')=P(A_{12})P(A_{13})$$.
(7) is quite easy if you approach it through the right direction as given in the hint. Total number of pairs sharing the birthday is $$X=\sum_{i\neq j}X_{ij}$$. Using linearity of expectation, we have $$E[X]=\sum_{i\neq j}E[X_{ij}]$$, which is by equal to $${n\choose 2}E[X_{ij}]$$, by symmetry (any $$i,j$$). $$E[X_{ij}]=P(X_{ij}=1)=\frac{1}{365}$$.
(8) is also easy in formulation, but a little bit more tedious while calculating. Also, it's enough to calculate either the second moment or the variance, since the other can easily be deducted. I'm voting for the second moment: $$E[X^2]=E\left[\left(\sum_{i\neq j}X_{ij}\right)\left(\sum_{k\neq l}X_{kl}\right)\right]=E\left[\sum_{i\neq j}X_{ij}^2\right]+E\left[\sum_{(i,j)\neq (k,l)}X_{ij}X_{kl}\right]$$ $$X_{ij}=X_{ij}^2$$ because they're binary. So the first term above is nothing but $$E[X]$$. In the second term we can assume $$(i,j)$$ is always ordered such that $$i< j$$, and similarly $$k for $$(i,j)\neq (k,l)$$ to make sense. The equality case is handled in the first sum. In the second sum, the expectation goes inside. And, we know $$E[X_{ij}X_{kl}]=P(X_{ij}X_{kl}=1)=\frac{1}{365^2}$$ from (3) and (4). And, there are $${n\choose 2}^2-{n \choose 2}$$ terms in the second summand.