# In most locality sensitive hashing implemensions of SimHash, why is the cosine distance used and not the euclidean distance?

In Chapter 3 of Mining of Massive Datasets, the basis of locality sensitive hashing is explained. They notably mention simhash for the cosine distance, where random hyperplanes are generated, and for each hyperplane, the projection of the vector to be hashed onto the hyperplane's normal is used for hashing the vector. They highlight that to instead measure euclidean distance, one can involve the use of a value $$a$$ as a segment length, used to split all hyperplane normals into some number of $$a$$-length segments. For each hyperplane, the segment into which the vector's projection falls into is used as its hash output. Hence the concatenation of this operation on each hyperplane generates a hash.

Yet a number of implementations, including what seems to be one of the most authoritative (falconn), do not use segments at all, and instead simply do a binary output depending on which side of the hyperplane the projection falls into. Why is this ? Why are segments not used ? What does the cosine distance have over the euclidean distance ?

• Are you sure the implementations are for Euclidean and not Cosine distance? Cosine has some advantages over Euclidean but that is worthy of its own question. Oct 15 '18 at 17:27
• Unless I am misunderstanding your comment, that's what I highlight: They use cosine distance, not euclidean distance. See infolab.stanford.edu/~ullman/mmds/book.pdf, and github.com/FALCONN-LIB/FALCONN Oct 15 '18 at 18:21
• @Solomonoff'sSecret Oct 15 '18 at 18:47
• Okay, they use cosine distance. In that case the real question is why use cosine distance, not why use a certain version of LSH. Oct 15 '18 at 19:29
• @Solomonoff'sSecret You are right. I have fixed the question. Oct 15 '18 at 19:31