import numpy as np


def maharanobis_distance(z, zc, inv_covar):

    # z.shape: (num, the number of dimension)
    dz = z - zc
    rhs = (inv_covar @ dz.T).T
    distance = np.sum(dz * rhs, axis=1)
    return distance

import numpy as np


def maharanobis_distance(z, zc, inv_covar):

    # z.shape: (num, the number of dimension)
    dz = z - zc
    rhs = (inv_covar @ dz.T).T
    distance = np.sum(dz * rhs, axis=1)
    return distance

# z.shape: (num, the number of dimension)