Joint distribution of the first and second repeat in a sequence of random numbers

42 Views Asked by At

I have iid random variables $Z_1,Z_2,...$ that are uniformly distributed on the set $\{1,2,...,n\}$. I define $X(n)=\min\{k:Z_k=Z_j\text{ for some }j<k\}$ and $Y(n)=\min\{k:Z_k=Z_j,Z_i=Z_l\text{ for some }j<k \text{ and }i<l<k\}$ so X(n) is the first repeat of a number and Y(n) is the second repeat (not necessarily a repeat of the same number as the first repeat.). I'd like to calculate the joint distribution and I'm not sure if I'm doing it correctly: $$P(X(n)\leq x, Y(n)\leq y)=P(Y(n)\leq y|X(n)\leq x)P(X(n)\leq x)$$ $$=P(X(n)\leq x)\sum_{j=2}^{x}\frac{P(Y(n)\leq y,X(n)=j)}{P(X(n)=j)}$$ $$=(1-\prod_{k=1}^{x-1}(1-\frac{k}{n}))\sum_{j=2}^{x}\frac{1-\prod_{i=j}^{y-1}(1-\frac{i}{n})}{\frac{j-1}{n}\prod_{k=1}^{j-2}(1-\frac{k}{n})}=(1-\prod_{k=1}^{x-1}(1-\frac{k}{n}))\sum_{j=1}^{x-1}\frac{1-\prod_{i=j+1}^{y-1}(1-\frac{i}{n})}{\frac{j}{n}\prod_{k=1}^{j-1}(1-\frac{k}{n})}$$ Edit: I corrected a mistake I made while writing it down.

I used $$P(X(n)\leq x)=1-P(X(n)> x)=1-\prod_{k=2}^{x}(1-\frac{k-1}{n})=1-\prod_{k=1}^{x-1}(1-\frac{k}{n})$$ $$P(X(n)=j)=\frac{j-1}{n}\prod_{k=2}^{j-1}(1-\frac{k-1}{n})=\frac{j-1}{n}\prod_{k=1}^{j-2}(1-\frac{k}{n})$$, where $\frac{j-1}{n}$ is the chance to draw a repeat in draw number jth, because $j-1$ unique integers have been drawn so far. $1-\frac{k}{n}$ is the chance to draw a unique number in draw number $k+1$. For the last part, if j is the first repeat, there can't be a second repeat in the first jth draws: $$P(Y(n)\leq y,X(n)=j)=1-\prod_{i=j+1}^{y}(1-\frac{i-1}{n})=1-\prod_{i=j}^{y-1}(1-\frac{i}{n})$$

Is this so far correct?