added mahalanobis distance, fixed ber calculation