affinity calculating