This document contains R code to calculate Mahalanobis distance using populations and samples. It defines two functions: ManDP calculates Mahalanobis distance between populations by computing the pooled covariance matrix from the individual population covariance matrices, while ManDS calculates it between samples by directly combining the sample covariance matrices. Both functions take in four lists of x and y values, calculate their covariances and means, construct matrices from these, and return the Mahalanobis distance as the square root of the product of these matrices.