converts distance to a similarity score