# Using common samples to numerically estimate pairwise equality of three random variables

Let $$X,Y,Z$$ be three discrete random variables which I can numerically sample. I need to numerically estimate the probability that $$X=Y$$ and the probability that $$X=Z$$. I would like to know whether the algorithm that I describe below is suited to this goal. In particular, I would like to know whether it is acceptable to use the same samples from $$X$$ to estimate both quantities.

My current algorithm generates $$n$$ independent samples of each random variable. That is, I generate three vectors: $$(x_1,\ldots,x_n)\\ (y_1,\ldots,y_n)\\ (z_1,\ldots,z_n)$$ Associated to these vectors, I define two counting variables as follows, $$c_{XY}:=\sum_{i=1}^n\displaystyle\delta_{x_iy_i}\qquad c_{XZ}:=\sum_{i=1}^n\delta_{x_iz_i}$$ where $$\delta_{ij}$$ is the Kronecker delta. Finally, I estimate my probabilities in the following way: $$P(X=Y)\approx \frac{c_{XY}}{n}\qquad P(X=Z)\approx \frac{c_{XZ}}{n}$$.

I would greatly appreciate any feedback.

## 1 Answer

Your two estimators $$c_{XY}/n$$ and $$c_{XZ}/n$$ are unbiased estimators of $$P(X=Y)$$ and $$P(X=Z)$$ respectively. They are not independent, however. Whether that is "acceptable" might depend on what you're using them for.