def moore_penrose_psuedoinverse(E):
    """Return the Moore Penrose Psuedoinverse of the given Matrix

    Parameters
    ----------
    E: np.ndarray
        The sigma matrix returned after performing SVD on matrix W
    
    Returns
    -------
    np.ndarray
        returns Moore Penrose Psuedoinverse of the input matrix
    """

    E_plus = E.copy()
    for i in range(min(E_plus.shape[0], E_plus.shape[1])):
        if E_plus[i][i] > 1e-6 :    # actually should be != 0
            E_plus[i][i] = (1/E_plus[i][i])
        else: E_plus[i][i] = 0
    return E_plus.transpose()