# Similarity between $2$ sets

I have two sets $S_1=\{1,2,3,4\}$ and $S_2\{1,2,3,4,5,6,7,8,9\}$.

• $Intersection (I) = 4$
• Number of non-equal elements (N) = $5$

I am trying to find a way to combine the intersection and number of non-equal elements to compute the similarity between the two sets. The higher the number of non-equal elements the lower the similarity

Solution (Gerry Myerson) Let $I$ be the size of the intersection, $N$ the number of non-equal elements. The similarity between $S_1$ and $S_2$ is then $I~/~(N+1)$

• Let $I$ be the size of the intersection, $N$ the number of non-equal elements. You could use $I/(N+1)$. – Gerry Myerson May 2 '14 at 9:04
• @GerryMyerson I just have one problem. How can I normalize it between $0$and $1$. because suppose that $I = 6$ and $N = 2$ it wont be between $0$ and $1$ that's what i am trying to figure out now. – Hani Gotc May 2 '14 at 9:19
• If that's what you want, please edit it into your question. – Gerry Myerson May 2 '14 at 12:39

$$sim(S_1,S_2) = |S_1 \cap S_2| ~/~ (|S_1 {\tiny \triangle}~ S_2| + 1),$$
$$norm(S_1,S_2) = sim(S_1,S_2) ~/~ |S_1 \cup S_2|.$$
Of course, whenever $|S_1 \cup S_2| = 0$, we let $norm(S_1,S_2) = 0$.
• Is it possible to normalize it between $0$ and $1$? – Hani Gotc May 2 '14 at 9:22