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...
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)