0


Python绘制概率曲线一

Python绘制概率曲线一

解释

这里是使用matplotlib来绘制正态分布的曲线。

代码实现

  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. deftest1(n, m=500):
  4. out =[]
  5. result = np.random.normal(1,5, n * m)print(result)for i inrange(m):
  6. average0 =0for j inrange(n):
  7. average0 += result[n * i + j]if j == n -1:
  8. out.append(average0 / n)
  9. average0 =0print(out)
  10. plt.hist(out,bins=25)
  11. plt.title("test (1)")
  12. plt.xlabel("x")
  13. plt.ylabel("rate")
  14. plt.show()
  15. test1(5)
标签: 算法 leetcode python

本文转载自: https://blog.csdn.net/m0_54218263/article/details/123676513
版权归原作者 hhh江月 所有, 如有侵权,请联系我们删除。

“Python绘制概率曲线一”的评论:

还没有评论