Questions tagged [hamming-distance]

The Hamming distance is a mathematical distance function for a pair of strings (sequences) that can be computed with a binary calculation. It counts the number of symbols in the string that are different. Posts that are not about implementation may belong on https://math.stackexchange.com.

For the special case of two binary strings, it may be implemented as the bitcount of their XOR:

int H(int a, int b){
    return popcount(a^b);
}
291 questions
1
vote
1 answer

Breaking a Repeating-Key XOR Cipher

Challenge #6 Challenge File In this Cryptopals Challenge that I am currently working on. I have the correct Hamming function and feasible (though possibly incorrect) FindKey and XOR functions. So far, I have this code... import base64 def…
Phillip Sloan
  • 125
  • 1
  • 2
  • 9
1
vote
1 answer

XOR bitset when 2D bitset is stored as 1D

To answer How to store binary data when you only care about speed?, I am trying to write some to do comparisons, so I want to use std::bitset. However, for fair comparison, I would like a 1D std::bitset to emulate a 2D. So instead of…
gsamaras
  • 71,951
  • 46
  • 188
  • 305
1
vote
1 answer

Computing number of bits that are set to 1 for matching rows in terms of hamming distance between two data frames

I have two data frames of same number of columns (but not rows) df1 and df2. For each row in df2, I was able to find the best (and second best) matching rows from df1 in terms of hamming distance, in my previous post. In that post, we have been…
alaj
  • 187
  • 1
  • 10
1
vote
1 answer

Assertion error in OpenCV.norm

I'm looking for the difference two image in video with the help of hamming distance. Here is my code: #include #include "opencv2/opencv.hpp" using namespace cv; int main(int argc, char** argv) { char const* filename =…
Andrio Skur
  • 755
  • 9
  • 22
1
vote
0 answers

Find strings with lowest Hamming distance

I have a list of (alphabetical) strings, and I want to compare a string against a list of other strings, and find which string has the lowest Hamming distance compared to that string. Also, the list of strings used for comparison is known at compile…
Mitsos101
  • 551
  • 3
  • 15
1
vote
1 answer

DNA Hamming Distance

If I represent DNA as binary values, what is the best way of computing distance between them. So : A = 00, T = 11, G = 01 and C = 10 Hamming Distance between ATGC and TAAC is 3, however their binary representations give a different answer: Hamming…
Y.V
  • 15
  • 1
  • 4
1
vote
0 answers

SICStus Prolog: FFI slow, how to calculate Hamming weight fast?

When I ran the foreign code sample c1/2, as shown in the SICStus Prolog 4.3.2 manual, and compared its runtime to the corresponding Prolog code Y is X+9, I got strange timing results: p(N, X) :- ( true1G, X is N+9, false ; X is N+9 ). q(N, X) :- (…
repeat
  • 18,496
  • 4
  • 54
  • 166
1
vote
1 answer

Generate all unordered pairs of bit strings with Hamming distance at most 2

I'm looking for an efficient way to generate all unordered pairs of bit strings (represented as integers) that have Hamming distance at most 2. In this answer, it is shown how this is quite efficiently done for pairs having Hamming distance 1. In…
Gideon
  • 433
  • 4
  • 15
1
vote
0 answers

create a word series with defined hamming distance among elements

I want to obtain all words of specific length/alphabet which have a minimal hamming distance among themselves. I'm not a mathematician so I try to show an example to make it clear what I need. Word Length L = 4 Word Alphabet A = {0,1} Word Alphabet…
user1587451
  • 978
  • 3
  • 15
  • 30
1
vote
1 answer

Computing Inverse hamming distance among a list of words

I'd like to find the number of the same characters in the same position in each word of a list of words. So for example the end result would be a matrix of the words compared to other words in the list which shows inverse hamming distance between…
user2258651
  • 383
  • 5
  • 8
1
vote
1 answer

Custom comparisons with Django (hamming distance)

I have the following code that allows me to find images of equal has (identical), but say I wanted to just find images with a hamming distance under a certain number, can that be incorporated into django querysets, or raw sql somehow? I don't want…
davegri
  • 2,206
  • 2
  • 26
  • 45
1
vote
0 answers

How can I find multiple homography when tracking object?

As known, for tracking objects in OpenCV we can use: FeatureDetector to find features DescriptorMatcher to match similarity between features of the desired object and features of current frame in video and then use findHomography to find the new…
Alex
  • 12,578
  • 15
  • 99
  • 195
1
vote
1 answer

using hamming distance algorithm to create index for fuzzy join with help of map reduce

I am New to Java and Map Reduce, and I am trying to write a Map Reduce program that reads the list words called "dictionary" in program and use hamming distance algorithm to generate all the words in the list having distance 1. I am able to generate…
1
vote
1 answer

Hamming distance and CRC

How to find the Hamming distance of a code generated by a certain CRC? Assume that I have a generating polynomial of order, say, 4 and 11 bits of data. How to compute the HD basing only on these information?
Jamie
  • 1,092
  • 3
  • 22
  • 44
1
vote
4 answers

Why is my program not following the conditionals that I set? Function issues?

I am trying to generate a random barcode_list with 6 UNIQUE barcodes that have a hamming distance of 3. The issue is that the program is generating a barcode list with duplicates and not the correct hamming distance. Below is the code. import…