how to compute similarities