Table of Contents
Cosine similarity is a mathematical measure used to determine the similarity between two vectors in a multi-dimensional space. In Excel, this can be calculated using the COS function, which computes the cosine of an angle given in radians. To calculate the cosine similarity between two vectors, the user must first convert the data into a numerical format and then use the COS function to calculate the cosine of the angle between the two vectors. This will result in a value between -1 and 1, where a higher value indicates a higher degree of similarity between the two vectors. By using this method, Excel can be utilized as a convenient tool for calculating cosine similarity, making it a useful tool for various data analysis and comparison tasks.
Calculate Cosine Similarity in Excel
Cosine Similarity is a measure of the similarity between two vectors of an inner product space.
For two vectors, A and B, the Cosine Similarity is calculated as:
Cosine Similarity = ΣAiBi / (√ΣAi2√ΣBi2)
This tutorial explains how to calculate the Cosine Similarity between vectors in Excel.
Cosine Similarity Between Two Vectors in Excel
Suppose we have the following two vectors in Excel:

We can use the following formula to calculate the Cosine Similarity between the two vectors in Excel:
=SUMPRODUCT(A$2:A$9,B2:B9)/(SQRT(SUMSQ(B2:B9))*SQRT(SUMSQ($A$2:$A$9)))
The following screenshot shows how to use this formula:

The Cosine Similarity between the two vectors turns out to be 0.965195.
Note that we interpret the value for Cosine Similarity as follows:
- A value of -1 indicates maximum dissimilarity
- A value of 0 indicates that the two vectors are orthogonal
- A value of 1 indicates maximum similarity
A value of 0.965195 indicates a high level of similarity between the two vectors in our example.
The following tutorials explain how to calculate Cosine Similarity in other statistical software:
For an in-depth explanation of Cosine Similarity, refer to the following Wikipedia article:
Cite this article
stats writer (2024). How can I calculate cosine similarity in Excel?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-calculate-cosine-similarity-in-excel/
stats writer. "How can I calculate cosine similarity in Excel?." PSYCHOLOGICAL SCALES, 4 May. 2024, https://scales.arabpsychology.com/stats/how-can-i-calculate-cosine-similarity-in-excel/.
stats writer. "How can I calculate cosine similarity in Excel?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-calculate-cosine-similarity-in-excel/.
stats writer (2024) 'How can I calculate cosine similarity in Excel?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-calculate-cosine-similarity-in-excel/.
[1] stats writer, "How can I calculate cosine similarity in Excel?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, May, 2024.
stats writer. How can I calculate cosine similarity in Excel?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
