weixin_44668354
DT派
2019-09-30 22:41

sorted 函数bug,有没有大神帮忙指点下这是什么错误

  • python
  • list

import numpy as np

c = np.loadtxt('data.csv', delimiter = ',', usecols = (6, ), unpack = True)
print ("median =", np.median(c))
sorted = np.msort(c)
print ("sorted =", sorted)

N = len(c)
print("middle =", sorted[(N - 1)/2])
print("average middle =", (sorted[N / 2] + sorted[(N - 1) / 2]) / 2)

print("variance =", np.var(c))
print("variance from definition =", np.mean((c - c.mean()) ** 2))图片说明


  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答