Added 1/(1+d_mahal) to avoid problems of small number precision