def my_mahalanobis_distance(x, y):
    """
    x: array of shape (4,) x[0]: mu_x_1, x[1]: mu_x_2, 
                            x[2]: cov_x_11, x[3]: cov_x_22
    y: array of shape (4,) y[0]: mu_ y_1, y[1]: mu_y_2,
                            y[2]: cov_y_11, y[3]: cov_y_22 
    """
return sp.spatial.distance.mahalanobis(x[:2], y[:2], np.linalg.inv(np.diag(
    x[2:]) + np.diag(y[2:])))
Nearest neighbors with uncertain points