How to Calculate Manhattan Distance in Excel


The Manhattan distance between two vectors, A and B, is calculated as:

Σ|Ai – Bi|

where i is the ith element in each vector.

This distance is used to measure the dissimilarity between two vectors and is commonly used in many machine learning algorithms.

The following example shows how to calculate the Manhattan distance between two vectors in Excel.

Example: Calculating Manhattan Distance in Excel

Suppose we have the following two vectors, A and B, in Excel:

To calculate the Manhattan distance between these two vectors, we need to first use the ABS() function to calculate the absolute difference between each corresponding element in the vectors:

Next, we need to use the SUM() function to sum each of the absolute differences:

The Manhattan distance between the two vectors turns out to be 51.

Additional Resources

The following tutorials explain how to calculate other distances in Excel:

How to Calculate Euclidean Distance in Excel
How to Calculate Hamming Distance in Excel

Leave a Reply

Your email address will not be published.