Percentage Similarity within Range

31 Views Asked by At

I am trying to calculate the similarity between two times. In C# I'd get these values using something like TimeStamp.Ticks; in general, I'm thinking of some numeric value that corresponds to the amount of time since midnight.

The simplified thought experiment I run to even get a feel for what I'm after is something like this: Given a hypothetical scenario where my possible range of values is

T = { 1, 2, 3, 4 }

I want a function s(m, n) for m and n in T s.t. the following table holds:

m n s
1 1 100%
1 2 75%
1 3 50%
1 4 25%
2 1 75%
2 2 100%
2 3 75%
2 4 25%

etc.; m = 3 and 4 are symmetric with m = 2 and 1, respectively.

From this experiment, it seems clear that the s I am looking for is something like

$$s(m,n) = 1-\frac{|m-n|}{R}$$

where R is just the range of T, something like max - min (+ 1?). This of course breaks down to something like

$$s(m,n) = 1-|\frac{m}{R}-\frac{n}{R}|$$

so just the inverse of the difference in points percentage of m and n along their common range. This s ends up looking something like a tent, which I suppose makes sense owing to using the absolute difference.

I guess my question to anyone that has any experience with percentages within ranges like this would be, how commonly used is something like this? This isn't classic percent difference, but it is at least some kind of symmetric percent difference (or similarity, rather). I guess my hesitation is I don't find much like this in the literature, except for the idea of difference in percentage points - is that a legitimate metric for gauging similarity? Another hesitation is I don't necessarily care for the sharp tent shape I'm proposing here; intuitively, I would think something more Gaussian in nature would serve better. Maybe I make this s the input to a sigmoid and that's what I'm looking for, but wanted to throw this out to the community in case anyone's already tried to do something (ahem) similar.