Python NumPy中的np.mean()vs np.average()吗?

Python NumPy中的np.mean()vs np.average()吗?,第1张

Python NumPy中的np.mean()vs np.average()吗?

np.average采用可选的权重参数。如果未提供,则等效。看一下源代码:Mean,Average

np.mean:

try:    mean = a.meanexcept AttributeError:    return _wrapit(a, 'mean', axis, dtype, out)return mean(axis, dtype, out)

np.average:

...if weights is None :    avg = a.mean(axis)    scl = avg.dtype.type(a.size/avg.size)else:    #pre that does weighted mean hereif returned: #returned is another optional argument    scl = np.multiply(avg, 0) + scl    return avg, sclelse:    return avg...


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5617009.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存