CalcD function

Calculate Patterson's D-statistic