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
2
votes
3 answers

What's the right way to measure locations within a radius in mySQL?

I'm writing an app that needs to allow a user to select elements that are within some radius of their location. There is no way to know how many locations there will be ultimately, but it might be tens of thousands. The user doing the search is…
Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236
2
votes
0 answers

HOTP/TOTP client token uniqueness

Is it possible to use TOTP to generate tokens from multiple channels (where a channel is defined as a "user" using a certain shared key K_c for channel c), and in so doing identify the channel itself from the OTP? For example, if two OTP's were…
2
votes
1 answer

Is there a formal name for this kind of distance between two binary string?

We all know that the Hamming distance of two binary strings is the number of different bits. While for two binary strings:1110 and 1101, if I want to discribe their similarity with the number of same bits from the highest bit. (In this example, from…
firefly
  • 183
  • 1
  • 2
  • 7
1
vote
2 answers

Hamming distance in k-means clustering

I want to use the hamming distance in kmeans clustering in Matlab, but I get an error saying that my data must be binary. Is there anyway around this? The data matrix that I use can't be binary (it has a physical interpretation that must allow for…
1
vote
1 answer

Hamming distance

My work is in genetics and I'm using the Hamming distance (in Matlab) to calculate the genetic distance between genotypes of a virus. For example: Type 1 has structure 01234 and Type 2 has structure 21304 etc. Obviously there are many genotypes…
1
vote
1 answer

How do I add another column to a PostgreSQL subquery?

I wasn't too sure how to phrase this question, so here are the details. I'm using a trick to compute the hamming distance between two bitstrings. Here's the query: select length(replace(x::text,'0','')) from ( select code # '000111101101001010'…
Bat Masterson
  • 1,164
  • 3
  • 11
  • 27
1
vote
1 answer

Hamming Distance: unclear logic step involving bitwise operation

Solving some leetcode question I encountered the hamming distance problem (which I almost forget). the question was: Given two integers, return the Hamming distance between them. Now, I know and understand the following logic: def…
1
vote
0 answers

HashMap implementation such that that inputs less than some specified hamming distance away from a key map to the same bucket as that key?

Okay, this one is a bit of a doozy, but here goes... ‎ I have computed perceptual hashes for some amount of images where I wish to count occurrences of near-duplicates. The way this is currently being done is by throwing every hash into a HashMap,…
memeko
  • 163
  • 1
  • 7
1
vote
0 answers

Extract the baseline and focal length using KITTI 2015 stereo dataset

I am new to image processing and I need to use the KITTI 2015 stereo images for performing a depth estimation using Census transform and hamming distance. For this I to need to find out how to extract the baseline and focal length from the…
1
vote
0 answers

Is there a function that determins the minimum distance of the code

is there mathlabs functions that when given (n,k) of a generalized array code it is able to generate all non-zero code words using (n,k) then find the minimum distance of the code, and determine the error detection capability td and error correction…
Swag lord
  • 19
  • 1
1
vote
1 answer

Is Cyclic Redundancy Check (CRC) able to detect the wrong sequence of data?

We are using a CRC to detect errors in a set of data which is transferred over a bus. The byte-wise CRC of the entire data calculated in the source and proved in the destination. It may happen that the order of data changed during transfer. Is CRC…
Mojtaba
  • 306
  • 3
  • 15
1
vote
0 answers

Algorithm to Check if Strings are Equal Allowing Rotations and up to K Replacements

Imagine the problem of finding if one string "STR1" is a rotated version of another string "STR2". This problem is simple and just requires searching for either string in the other string concatenated with itself. However how would you solve this…
1
vote
0 answers

Calculating the hamming distance between the binary value of characters between two strings in R

I need help guys! Imagine I have a vector fp with n elements. Each element is a string with 64 characters (always) and I want to build a distance matrix of all the elements. Each character of each element is either hexadecimal…
mrjoao93
  • 23
  • 2
1
vote
1 answer

How to calculate Hemming Distance in CosmosDB?

Each item in my collection has a 64-bit number, which represents dhash of the image. I want to run a query by this field, which will return all items, that have Hamming Distance more or less than some param. In MySQL I would use BIT_COUNT function.…
1
vote
1 answer

Find the Hamming distance between string sequences

I have a dataset of 3156 DNA sequences, each of which has 98290 characters (SNPs), comprising the (usual) 5 symbols : A, C, G, T, N (gap). What is the optimal way to find the pairwise Hamming distance between these sequences? Note that for each…
Sudaraka
  • 125
  • 7