python 返回数组的相邻成员的平均值。用于绘制箱数。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 返回数组的相邻成员的平均值。用于绘制箱数。相关的知识,希望对你有一定的参考价值。

def mid(x, base=None):
    '''Return mean value of adjacent member of an array.
    Useful for plotting bin counts.
    '''
    if base is None:
        x = np.asarray(x)
        return  (x[1:] + x[:-1])/2.
    elif base == 'log':
        return np.exp(mid(np.log(x)))
    elif base == 'exp':
        return np.log(mid(np.exp(x)))
    else:
        assert base > 0
        return np.log(mid(base**x))/np.log(base)

以上是关于python 返回数组的相邻成员的平均值。用于绘制箱数。的主要内容,如果未能解决你的问题,请参考以下文章