How to calculate hamming distance for more than 2 inputs - math

here the question
1001110
1110101
1010011
0011011
How can calculate hamming distance for this example. Can you explain pls for more than 2 inputs.

Do you mean the minimum Hamming distance? The minimum Hamming distance of a code is the smallest Hamming distance between a pair of codewords. In your example code, which contains four codewords, the two closest codewords are the last two codewords, and they differ in exactly two positions. Hence, the minimum Hamming distance of this code is 2.

Related

How do I assign weights using Kernel function based on a vector of pairwise Euclidean distance?

I want to quantify the dissimilarity between two group. Each group has 5 observations, so there are 25 combinations.
For each combination, I have calculated their pairwise Euclidean distance (based on feature space). So I have had a vector of pairwise Euclidean distances as follows:
set.seed(1)
runif(n=25, min=50, max=90)
[1] 60.62035 64.88496 72.91413 86.32831 58.06728 85.93559 87.78701 76.43191 75.16456 52.47145 58.23898 57.06227 77.48091
[14] 65.36415 80.79366 69.90797 78.70474 89.67624 65.20141 81.09781 87.38821 58.48570 76.06695 55.02220 60.68883
I want to use Kernel function to assign weights to the 25 combinations based on the vector of pairwise Euclidean distances. Shorter distance, larger weight.
How can I do it in R?
I have limited knowledge about kernel. Thank you in advance for any suggestions!
I would really appreciated it even if you can give me some hints about the mathematical formula without any programming.

Hamming distance

I'm reading the book of Computer networks by Andrew S. Tanenbaum. I'm confused about the hamming distance in this paragraph. Why does it say the Hamming distance is 3 in this construction? Thanks.
You are confusing between the figure and the written part.They are 2 different examples.In the diagram example of (11,7) Hamming code is given,while the example above it is discussing about (11,29).
The Hamming distance between two strings of equal length is the number
of positions at which the corresponding symbols are different.
Hamming distance of (11,29) will be 3 as 11=01011 and 29=11101
Reach out if you want something else.
Cheers

Why find the Hamming Distance in Dynamical Networks?

In dynamical networks, one may calculate the Hamming distance to compare the similarity between two graphs, can anyone explain how?
Assuming that the Hamming distance of two graphs have equal edge density, what is the difference between Hamming distance and expected Hamming distance between two independent Erdos-Renyi random graphs? How does the later arise?
The Hamming distance measures the minimum number of substitutions required to change (transform) one mathematical 'object' (i.e. strings or binary) into another.
So in network theory it can be defined as a the number of different connections between two networks (it can be formulated also for not equally-sized networks and for weighted or directed graphs). In a simple case in which you have two Erdos-Renyi networks (the adjacency matrix has 1 if the node pair is connected and 0 if not) the distance is mathematically defined as follows:
The values that are subtracted are the two adjacency matrix. If you take two Erdos-Renyi networks with wiring probability of 0.5 and compute the hamming distance between them you should get a value around 0.5. I generated different Erdos-Renyi graph and their Hamming distances produced a Gaussian curve around 0.5 (as we can expect; see below).
If it is needed I can give you the code I used.

Determining the minimum Hamming Distance

How can I find the minimum Hamming Distance for the above?
I understand the string comparison idea and putting it into a table based on C0, C1, C2, etc but I'm not sure how to group the code above. Any suggestions? Thank you in advance.
Generally, to find the minimum Hamming distance you have to compute the Hamming distance of each pair of code words and then take the minimum of these. For special cases, e.g. linear codes there are theorems for quicker determination of the minimum Hamming distance (https://en.wikipedia.org/wiki/Linear_code).
In your example, the eye spots several adjacent code word pairs differing only in one bit, so as Egor wrote, the minimum Hamming distance is 1.

How the command dist(x,method="binary") calculates the distance matrix?

I have a been trying to figure that out but without much success. I am working with a table with binary data (0s and 1s). I managed to estimate a distance matrix from my data using the R function dist(x,method="binary"), but I am not quite sure how exactly this function estimates the distance matrix. Is it using the Jaccard coefficient J=(M11)/(M10+M01+M11)?
This is easily found in the help page ?dist:
This function computes and returns the distance matrix computed by using the specified distance measure to compute the distances between the rows of a data matrix.
[...]
binary: (aka asymmetric binary): The vectors are regarded as binary
bits, so non-zero elements are ‘on’ and zero elements are ‘off’. The
distance is the proportion of bits in which only one is on amongst
those in which at least one is on.
This is equivalent to the Jaccard distance as described in Wikipedia:
An alternate interpretation of the Jaccard distance is as the ratio of the size of the symmetric difference to the union.
In your notation, it is 1 - J = (M01 + M10)/(M01 + M10 + M11).

Resources