_cluster.py 文件源码

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

项目:ananke 作者: beiko-lab 项目源码 文件源码
def zscore(x):
    """Computes the Z-score of a vector x. Removes the mean and divides by the
    standard deviation. Has a failback if std is 0 to return all zeroes.

    Parameters
    ----------
    x: list of int
        Input time-series

    Returns
    -------
    z: list of float
        Z-score normalized time-series
    """
    mean = np.mean(x)
    sd = np.std(x)
    if sd == 0:
        z = np.zeros_like(x)
    else:
        z = (x - mean)/sd
    return z
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号