roboust technique to calculate affinity