logo_learn_stats

The best way to Calculate Hamming Distance in Excel

Posted on
banner 336x280


The Hamming distance between two vectors is just the sum of corresponding parts that fluctuate between the vectors.

banner 468x60

As an example, think we now have refer to two vectors:

x = [1, 2, 3, 4]

y = [1, 2, 5, 7]

The Hamming distance between the 2 vectors could be 2, since that is the full selection of corresponding parts that experience other values.

To calculate the Hamming distance between two columns in Excel, we will be able to utility refer to syntax:

=COUNT(RANGE1)-SUMPRODUCT(--(RANGE1 = RANGE2))

Right here’s what the components does in a nutshell:

  • COUNT unearths the full selection of observations within the first column.
  • RANGE1 = RANGE2 compares each and every pairwise observations between the columns and returns a TRUE or FALSE.
  • – – converts TRUE and FALSE values to 0 and 1.
  • SUMPRODUCT unearths the sum of all 1’s.

This educational supplies a number of examples of methods to utility this calculation in observe.

Instance 1: Hamming Distance Between Binary Vectors

Please see code displays methods to calculate the Hamming distance between two columns in Excel that each and every include most effective two imaginable values:

Hamming Distance in Excel

The Hamming distance between the 2 columns is 3.

Instance 2: Hamming Distance Between Numerical Vectors

Please see code displays methods to calculate the Hamming distance between two columns in Excel that each and every include a number of numerical values:

Example of Hamming distance in Excel

The Hamming distance between the 2 vectors is 7.

Alternative Assets

The best way to Calculate the Ruthless Absolute Rerouting in Excel
The best way to Normalize Information in Excel
The best way to To find Outliers in Excel

banner 336x280

Leave a Reply

Your email address will not be published. Required fields are marked *