# Compute probability from distance-score

I compute Euclidian distances between a point I want to analyze and a set of points I have. I want to sort my points by decreasing "similarity".

I used to compute a "score" by inverting the distance ($$s=1/d$$), and use the $$\cfrac{s_i}{\sum_k s_k}$$ as a similarity that varies between $$0$$ and $$1$$.

I have seen that the $$softmax$$ function can also be used, the difference being that it uses $$e^{1/d}$$ as the score.

Which function would be closer to computing a kind of "probability"? I should apologize for probably mixing terms...

• Probability of what? Both give nonnegative scores that sum to one. Neither is particularly anything like a probability. Softmax will decay quickly beyond the closest point, while the sum one will distribute scores more widely. Feb 4 '17 at 1:40
• If you're not familiar, you might want to look at kernels. Feb 4 '17 at 1:42
• @Dougal, thank you, your first comment answers my question ... and your second one gives me homework ;) If you add that as an answer I'll accept it. Feb 4 '17 at 11:53

Credits to @Dougal for his comment-answer:

Both give nonnegative scores that sum to one. Neither is particularly anything like a probability. Softmax will decay quickly beyond the closest point, while the sum one will distribute scores more widely.

The decay part is interesting: $$e^{1/x}$$ is a lot bigger than $$1/x$$, so $${\sum_k e^x}$$ will be a lot bigger than $${\sum_k 1/x}$$, considering the value of $$k$$.

For those still looking for different answers, I was finding individual probabilities (something like Sigmoid) for similarity values provided by different algorithms. This is what I am doing.. $$(1-e^{-1/x})/(1+e^{-1/x})$$

Considering that similarity provides value from 0 to 1, where o being most relevant one. This has provided me with pretty good results, not sure if something like this can used for distance as well, may be taking modulus of x in above equation solves the problem. $$(1-e^{-1/|x|})/(1+e^{-1/|x|})$$

Please let me know if someone tries this.

Thanks