# Why is the cosine similarity between these (seemingly uncorrelated) vectors so high?

I am calculating the correlations between vectors of experimental data by a variety of methods (Pearson's, cosine similarity, Euclidian distance, etc.). Most the results look fine, but occasionally the cosine similarity will seem extremely inflated.

For example, these two vectors don't appear to be correlated. The Pearson's correlation coefficient is 0.16 (this makes sense). The cosine similarity is 0.995. Why is it so high?

# two vectors
x1 <- c(2000,2000,2000,1987.5,2000,2000,2000,1910,1926.66666666667,2000,1723.33333333333,2000,2000,1992.5,2000,2000,2000,1997.5,2000,1516.66666666667)
x2 <- c(10000,8045,10000,9985,10000,10000,10000,8866.66666666667,10000,8285,8173.33333333333,10000,9590,9355,10000,10000,9990,10000,7345,9557.5)

# visually, they seem mostly uncorrelated
plot(x1, x2)

# Pearson's correlation coefficient is 0.16 (this makes sense)
cor(x1, x2)

# The cosine similarity is 0.995.  Why?
cossim <- function(A, B) sum(A*B) / ( sqrt(sum(A^2)) * sqrt(sum(B^2)) )  # cosine similarity
cossim(x1, x2)


Edit: by request, I added an image that includes the origin in the axes scales. I guess I understand the motivation for this, but I still don't see why this is a 0.995. I would imagine that the vectors are more than 0.005 "different."

• Please include a plot of your data with the origin at x1=0 and x2=0. That might help explain your result and allow you to post an answer to your own question. – EdM Nov 4 '19 at 16:25
• The answer might become obvious if you were actually to draw these points as vectors, for then you would include the origin $(0,0)$ in the plot, forcing you to see how they are all closely clustered in a common direction. The correlation doesn't account for the origin at all: it adopts its own origin (the point of mean values). – whuber Nov 4 '19 at 17:06
• Re the edit: your code indicates there are 21 points, whereas the plots show only 10 or 11 distinct locations. Evidently a majority of the points are virtually identical, leading to very high similarity, but your plotting method does not reveal that. Your intuition would be helped by choosing a more accurate visualization. (Jittering would be a good choice.) – whuber Nov 4 '19 at 18:15
• Thanks for the useful comments so far. I guess I didn't appreciate the importance of the (0,0) point which is created by the lack of mean-centering (as in Pearson). If there is no special importance of (0,0) for a particular vector, does that mean that cosine similarity is inappropriate? For example, some of my experimental results are the log of a physical quantify, and (0,0) doesn't have a significant meaning in log space. – Arthur Nov 4 '19 at 20:29