simulate.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:GraphTime 作者: GlooperLabs 项目源码 文件源码
def scale_variance(Theta, eps):
        """Allows to scale a Precision Matrix such that its
        corresponding covariance has unit variance

        Parameters
        ----------
        Theta: ndarray
            Precision Matrix
        eps: float
            values to threshold to zero

        Returns
        -------
        Theta: ndarray
            Precision of rescaled Sigma
        Sigma: ndarray
            Sigma with ones on diagonal
        """
        Sigma = np.linalg.inv(Theta)
        V = np.diag(np.sqrt(np.diag(Sigma) ** -1))
        Sigma = V.dot(Sigma).dot(V.T)  # = VSV
        Theta = np.linalg.inv(Sigma)
        Theta[np.abs(Theta) <= eps] = 0.
        return Theta, Sigma
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号