# Binary distance measure

I want a metric - not an answer - for this.

If I have a main binary sequence - 00100 I want a measure to tell me how far away another binary sequences 1's are relating to the sequence of interest.

So comparing my main sequence with these:

A - 01000

B - 10000

I want to say that B is X% further from the main sequence compared to Y% for sequence A. By further I mean the distance of the positive entries of one sequence to the positive entries of another - their index in the sequence.

Any extant metrics for this type of distance-specific binary sequence analysis.

I dont want a measure to say how similar the sequences are, I want to say how much further one is from another.

I am not doing homeworks or jobs or anything - I am 30 just tinkering with protein sequence analysis and I want a metric that does this, that is all.

U.

• Are you looking for Hamming distance, perhaps? Commented May 8, 2018 at 9:52
• @JanKukacka - No, Hamming Distance gives me a integer value indicating the number of differences - so if there is a sequence 10000 and 01000 comparing to 00100, then both of these sequences have the same hamming distance, but the first sequence is "further" from the one of interest. Commented May 8, 2018 at 10:37
• @urema I'm saying that if you have a similarity measure, then the negative of it is a distance measure.
– Tim
Commented May 8, 2018 at 11:00
• @Tim - So from an integer similarity measure, taking the negative is the difference? You have to explain this my friend. SizeSimilarity measure gives me a value of 2 - similarity is 2.... so how is -2 a difference Commented May 8, 2018 at 11:13
• @urema things that are more distant are less similar to each other, so if you are able to measure distance, then similarity is opposite of it. That's all I'm saying.
– Tim
Commented May 8, 2018 at 11:20

A suggestion.

Why not say that each of your boolean is positioned onto an "indexline", i.e. $01234$. Seeing your reference ($R$), $A$ and $B$ binary sequences as row vectors, you could encode (->) them as

$R$ : $(0,0,1,0,0)$ -> $(0,0,2,0,0)$

$A$ : $(0,1,0,0,0)$ -> $(0,1,0,0,0)$

$B$ : $(1,0,0,0,0)$ -> $(0,0,0,0,0)$

and then compute

$\sum_i^5 \sum_j^5 |R_i-A^T_j| =13$

$\sum_i^5 \sum_j^5 |R_i-B^T_j| =10$

with the $0\%$ "further-value" being

$\sum_i^5 \sum_j^5 |R_i-R^T_j| =16$

Finally, you could, e.g, say things such as

$R$ is (undefined since) $\left(-1+\frac{16-16}{16-16}\right)$ but can be seen as $0\%$ further than itself.

or

$B$ is $\left(-1+\frac{16-10}{16-13}\right)=100\%$ further from $R$ than $A$ is...

You can also get rid of the absolute-value operator if you want to keep informations related to distance "direction".

• Kanak - everyone says to avoid saying thanks but I am not a robot - thank you, this was a great breakdown and gives me an insight into using encoding for my purposes. Commented May 13, 2018 at 10:24