确定Python 3.5上随机变量直方图的平方

时间:2017-01-29 09:20:30

标签: python-3.x statistics chi-squared

我试图为我的代码获取卡方值,这是在python上绘制随机变量的直方图。 虽然,它给了我统计数据的奇怪输出。 不确定我做错了什么。

 import matplotlib.pyplot as plt
 import numpy as np
 from scipy.stats import chisquare

 xv=[]

 for i in range(1,1001):
      s = np.random.uniform(-1,1,6)
      np.all(s >= -1)
      True
      np.all(s < 1)
      True
      temp = np.sum(s)

      xv.append(temp)


count, bins, ignored = plt.hist(xv, 100, normed=True)
plt.show()

print(chisquare(xv))

0 个答案:

没有答案