In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Xiaobian to share with you how Python draws probability distribution histogram, I believe most people still do not know how, so share this article for your reference, I hope you have a lot of gains after reading this article, let's go to understand it together!
preface
Histogram is a tool that can quickly show the probability distribution of data, intuitive and easy to understand, and loved by data enthusiasts. You may usually see at most matplotlib, seaborn and other high-level package libraries, similar to the following drawings.
I. Code
1. Case 1
import randomimport numpy as npimport matplotlib.pyplot as pltX = np.random.normal(loc=10, scale=2, size=(1, 1000))[0]Y = np.random.normal(loc=10, scale=1.0, size=(1, 1000))[0]P = np.ones(1000)P[:600] = 0np.random.shuffle(P)# print(P)Z = X + Y * Pplt.hist(Z, density=True, bins=150)plt.show()
2. Case 2
import randomimport numpy as npimport matplotlib.pyplot as pltn = 1000# p = 0.4U = []for i in range(1000): X = np.random.normal(loc=10, scale=2, size=(1, n))[0] Y = np.random.normal(loc=10, scale=1.0, size=(1, n))[0] P = np.ones(n) P[:600] = 0 np.random.shuffle(P) Z = X + Y * P a = 1 / pow(n * np.var(Z), 1/2) b = sum(Z) - n * np.mean(Z) u = a * b U.append(u)plt.hist(U, density=True, bins=60)plt.show()
1. Case 1
2. Case 2
That's all for "How Python draws probability distribution histograms." Thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.