# Similar numbers in a data set

#### alex01

##### New Member
Hi guys,

I am looking at a programming problem here, and would like to "deduce" a formula out of my problem.

I have an array of n (known) columns and two rows. I populate this array with number in a range (1 to n) let's say 1 to 5 for the example.

Code:
1 3 2 5 1 n
2 4 1 4 2 n
What I would like to determine is the possible number of occurrences of each set of two numbers. Example, what are the number of chances {1,2} occurs once in the array, or twice, or etc, but being able to determine it for each of the sets {3,4}, {2,1} etc.

I do understand that each number, occurs 1/range but I don't know how to link everything together to actually make a formula out of it, so if any of you has suggestion or an explanation ... i'd be really happy to read it.

Thanks

#### BGM

##### TS Contributor
Let see if your question is like this:

You have an array of i.i.d. discrete uniform random variables

$$X_{ij}, i = 1, 2, j = 1, 2, \ldots, n$$

with support $$\mathcal{X} = \{1, 2, \ldots, n\}$$

By independence, we have

$$\Pr\{X_{1j} = x_1, X_{2j} = x_2\} = \frac {1} {n^2}, \forall x_1, x_2 \in \mathcal{X}$$

Finally the number of times that a particular outcome $$(x_1, x_2)$$ appear among the columns will follow a Binomial distribution, write

$$\text{Binomial}\left(n, \frac {1} {n^2}\right)$$

Then the required probabilities can be directly calculated via its probability mass function.

#### alex01

##### New Member
Let see if your question is like this:

You have an array of i.i.d. discrete uniform random variables

$$X_{ij}, i = 1, 2, j = 1, 2, \ldots, n$$

with support $$\mathcal{X} = \{1, 2, \ldots, n\}$$

By independence, we have

$$\Pr\{X_{1j} = x_1, X_{2j} = x_2\} = \frac {1} {n^2}, \forall x_1, x_2 \in \mathcal{X}$$

Finally the number of times that a particular outcome $$(x_1, x_2)$$ appear among the columns will follow a Binomial distribution, write

$$\text{Binomial}\left(n, \frac {1} {n^2}\right)$$

Then the required probabilities can be directly calculated via its probability mass function.
Thank you for your answer, although (sorry i'm not good at math notations),but since I have an array of 2 row and n columns (and I'm looking for associations of

$$\text{the set}\left(1,2\right)$$

corresponding the to index 0 of the first cell of each row, both numbers at index have

$$\text{The probability } p=\frac{1}{36}$$

of occurring right ? so my probability of find

$$\text{the set}(1,2)$$

exactly one time is going to be

$$n(1/36)(35/35)^(6-1)$$

am i right ? So I am wondering, once I have calculated the probability of the first one occurring one OR more in my array, how can I calculate the probability of the second one also occurring one or more ?

so since I want the probability of the first set (1,2) to occur once or more I can change my formula to

$$\frac{n(n-1)}{2} (1/36)^2(35/25)^(n-2)$$ and so one for the first set, but how am i going to calculate, it for the second set after ? since there is X chances for the first set, how many chances are there for the second ?