A signature comparison score measures how different two authorship signatures are. It calculates a weighted difference for each feature and adds those contributions; lower scores indicate greater similarity. section 11.3.1 section 11.5.12
The calculation separates the comparison into three steps:
- Subtract corresponding feature values and take the absolute value, preventing negative differences from cancelling positive ones. section 11.3.1
- Multiply each difference by that feature's weight, reflecting its relative importance. section 11.3.1
- Add the weighted contributions to produce one overall score. section 11.3.1 section 11.5.12
Comparing two signatures
For [4.6, 0.1, 0.05, 10, 2] and [4.3, 0.1, 0.04, 16, 4], using weights [11, 33, 50, 0.4, 4], the feature contributions are 3.3, 0, 0.5, 2.4, and 8. Their total comparison score is 14.2. The weights are practical starting values rather than magical constants and can be tuned for stronger results. section 11.3.1
Listing 11.15 Compare two signatures
def get_score(signature1, signature2, weights):
'''
signature1 and signature2 are signatures.
weights is a list of five weights.
Return the score for signature1 and signature2.
>>> get_score([4.6, 0.1, 0.05, 10, 2],\
[4.3, 0.1, 0.04, 16, 4],\
[11, 33, 50, 0.4, 4]) #1
14.2
'''
score = 0
for i in range(len(signature1)): #2
score += abs(signature1[i] - signature2[i]) \ #3
* weights[i] #3
return score
The implementation compares corresponding list elements, applies absolute differences and weights, and returns the accumulated score. section 11.5.12
