Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

hamming

Hamming distance


Description

The Hamming distance is the number of positions where the values are different.

Usage

hamming(x, y)

Arguments

x, y

Numeric vectors.

Details

For vectors x and y, the Hamming distance is defined as

d(x, y) = ∑_i [x_i \neq y_i],

where the quantity in the brackets is 1 if the elements are not equal, and zero if the elements are equal. Relation to other definitions:

  • The hamming() function in scipy.spatial.distance divides the result by the vector length. Our function is equivalent to the SciPy version multiplied by the vector length.

  • Equivalent to the hamming calculator in Mothur for presence/absence vectors.

Value

The Hamming distance between x and y.


abdiv

Alpha and Beta Diversity Measures

v0.2.0
MIT + file LICENSE
Authors
Kyle Bittinger [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.