safe_cov_inverse function

Computes a numerically stable inverse of a covariance matrix