implement calculate simirality.