{"id":1015630,"date":"2024-12-27T12:09:27","date_gmt":"2024-12-27T04:09:27","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1015630.html"},"modified":"2024-12-27T12:09:29","modified_gmt":"2024-12-27T04:09:29","slug":"python%e5%a6%82%e4%bd%95%e7%94%9f%e6%88%90%e6%ad%a3%e6%80%81%e5%88%86%e5%b8%83","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1015630.html","title":{"rendered":"python\u5982\u4f55\u751f\u6210\u6b63\u6001\u5206\u5e03"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25095430\/f86b751e-55a7-4519-8103-593609f50420.webp\" alt=\"python\u5982\u4f55\u751f\u6210\u6b63\u6001\u5206\u5e03\" \/><\/p>\n<p><p> <strong>\u8981\u5728Python\u4e2d\u751f\u6210\u6b63\u6001\u5206\u5e03\uff0c\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u7684<code>numpy.random.normal()<\/code>\u51fd\u6570\u3001SciPy\u5e93\u7684<code>scipy.stats.norm<\/code>\u6a21\u5757\u3001\u6216\u4f7f\u7528Matplotlib\u5e93\u8fdb\u884c\u6570\u636e\u7684\u53ef\u89c6\u5316\u3002NumPy\u63d0\u4f9b\u4e86\u751f\u6210\u968f\u673a\u6570\u7684\u7b80\u5355\u65b9\u6cd5\uff0cSciPy\u63d0\u4f9b\u4e86\u66f4\u591a\u7edf\u8ba1\u529f\u80fd\uff0c\u800cMatplotlib\u5219\u7528\u4e8e\u7ed8\u5236\u5206\u5e03\u56fe\u3002<\/strong> \u4e0b\u9762\u5c06\u8be6\u7ec6\u63cf\u8ff0\u4f7f\u7528NumPy\u751f\u6210\u6b63\u6001\u5206\u5e03\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528NumPy\u751f\u6210\u6b63\u6001\u5206\u5e03\u7684\u6570\u636e\u975e\u5e38\u7b80\u5355\uff0c\u9996\u5148\u9700\u8981\u5bfc\u5165NumPy\u5e93\uff0c\u7136\u540e\u4f7f\u7528<code>numpy.random.normal()<\/code>\u51fd\u6570\u3002\u8be5\u51fd\u6570\u7684\u57fa\u672c\u7528\u6cd5\u662f<code>numpy.random.normal(loc=0.0, scale=1.0, size=None)<\/code>\uff0c\u5176\u4e2d<code>loc<\/code>\u662f\u5747\u503c\uff0c<code>scale<\/code>\u662f\u6807\u51c6\u5dee\uff0c<code>size<\/code>\u662f\u751f\u6210\u6570\u636e\u7684\u6570\u91cf\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u5173\u4e8e\u5982\u4f55\u5728Python\u4e2d\u751f\u6210\u6b63\u6001\u5206\u5e03\u7684\u8be6\u7ec6\u6307\u5357\uff1a<\/p>\n<\/p>\n<h2><strong>\u4e00\u3001NUMPY\u751f\u6210\u6b63\u6001\u5206\u5e03<\/strong><\/h2>\n<p><p>NumPy\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5e93\uff0c\u5e7f\u6cdb\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u3002\u5b83\u63d0\u4f9b\u4e86\u751f\u6210\u6b63\u6001\u5206\u5e03\u6570\u636e\u7684\u7b80\u5355\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h2>1\u3001\u57fa\u672c\u7528\u6cd5<\/h2>\n<\/p>\n<p><p>\u4f7f\u7528NumPy\u751f\u6210\u6b63\u6001\u5206\u5e03\u968f\u673a\u6570\u7684\u57fa\u672c\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u751f\u62101000\u4e2a\u5747\u503c\u4e3a0\uff0c\u6807\u51c6\u5dee\u4e3a1\u7684\u6b63\u6001\u5206\u5e03\u968f\u673a\u6570<\/strong><\/h2>\n<p>data = np.random.normal(loc=0, scale=1, size=1000)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>numpy.random.normal()<\/code>\u6765\u751f\u62101000\u4e2a\u7b26\u5408\u6b63\u6001\u5206\u5e03\u7684\u968f\u673a\u6570\uff0c\u5747\u503c\u4e3a0\uff0c\u6807\u51c6\u5dee\u4e3a1\u3002<\/p>\n<\/p>\n<p><h2>2\u3001\u8c03\u6574\u5747\u503c\u548c\u6807\u51c6\u5dee<\/h2>\n<\/p>\n<p><p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574<code>loc<\/code>\u548c<code>scale<\/code>\u53c2\u6570\u6765\u751f\u6210\u5177\u6709\u4e0d\u540c\u5747\u503c\u548c\u6807\u51c6\u5dee\u7684\u6b63\u6001\u5206\u5e03\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u62101000\u4e2a\u5747\u503c\u4e3a10\uff0c\u6807\u51c6\u5dee\u4e3a2\u7684\u6b63\u6001\u5206\u5e03\u968f\u673a\u6570<\/p>\n<p>data = np.random.normal(loc=10, scale=2, size=1000)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b64\u4ee3\u7801\u5c06\u751f\u62101000\u4e2a\u968f\u673a\u6570\uff0c\u8fd9\u4e9b\u968f\u673a\u6570\u7684\u5206\u5e03\u5177\u6709\u5747\u503c\u4e3a10\u548c\u6807\u51c6\u5dee\u4e3a2\u3002<\/p>\n<\/p>\n<p><h2>3\u3001\u751f\u6210\u591a\u7ef4\u6b63\u6001\u5206\u5e03<\/h2>\n<\/p>\n<p><p>NumPy\u4e5f\u652f\u6301\u751f\u6210\u591a\u7ef4\u6b63\u6001\u5206\u5e03\u3002\u4f8b\u5982\uff0c\u751f\u6210\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5176\u4e2d\u6bcf\u4e00\u884c\u4ee3\u8868\u4e00\u4e2a\u6b63\u6001\u5206\u5e03\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a5x3\u7684\u4e8c\u7ef4\u6570\u7ec4\uff0c\u6bcf\u884c\u5747\u503c\u4e3a0\uff0c\u6807\u51c6\u5dee\u4e3a1<\/p>\n<p>data = np.random.normal(loc=0, scale=1, size=(5, 3))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u751f\u6210\u4e00\u4e2a5\u884c3\u5217\u7684\u4e8c\u7ef4\u6570\u7ec4\uff0c\u6bcf\u884c\u7684\u5143\u7d20\u90fd\u662f\u4ece\u5747\u503c\u4e3a0\u3001\u6807\u51c6\u5dee\u4e3a1\u7684\u6b63\u6001\u5206\u5e03\u4e2d\u62bd\u53d6\u7684\u3002<\/p>\n<\/p>\n<h2><strong>\u4e8c\u3001SCIPY\u751f\u6210\u6b63\u6001\u5206\u5e03<\/strong><\/h2>\n<p><p>SciPy\u662f\u4e00\u4e2a\u7528\u4e8e\u6570\u5b66\u3001\u79d1\u5b66\u548c\u5de5\u7a0b\u7684\u5f00\u6e90Python\u5e93\u3002\u5b83\u63d0\u4f9b\u4e86\u8bb8\u591a\u9ad8\u7ea7\u7684\u6570\u5b66\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><h2>1\u3001\u751f\u6210\u6b63\u6001\u5206\u5e03\u6570\u636e<\/h2>\n<\/p>\n<p><p>SciPy\u7684<code>scipy.stats.norm<\/code>\u6a21\u5757\u53ef\u4ee5\u7528\u4e8e\u751f\u6210\u6b63\u6001\u5206\u5e03\u6570\u636e\u3002\u4ee5\u4e0b\u662f\u57fa\u672c\u7528\u6cd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from scipy.stats import norm<\/p>\n<h2><strong>\u751f\u62101000\u4e2a\u6b63\u6001\u5206\u5e03\u968f\u673a\u6570<\/strong><\/h2>\n<p>data = norm.rvs(loc=0, scale=1, size=1000)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u4f7f\u7528<code>scipy.stats.norm.rvs()<\/code>\u751f\u62101000\u4e2a\u968f\u673a\u6570\uff0c\u5747\u503c\u4e3a0\uff0c\u6807\u51c6\u5dee\u4e3a1\u3002<\/p>\n<\/p>\n<p><h2>2\u3001\u8ba1\u7b97\u6982\u7387\u5bc6\u5ea6\u51fd\u6570<\/h2>\n<\/p>\n<p><p>\u9664\u4e86\u751f\u6210\u968f\u673a\u6570\uff0c<code>scipy.stats.norm<\/code>\u8fd8\u53ef\u4ee5\u8ba1\u7b97\u6b63\u6001\u5206\u5e03\u7684\u6982\u7387\u5bc6\u5ea6\u51fd\u6570\uff08PDF\uff09\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u8ba1\u7b97\u4e00\u7ec4\u6570\u636e\u7684\u6982\u7387\u5bc6\u5ea6\u51fd\u6570<\/strong><\/h2>\n<p>x = np.linspace(-3, 3, 100)<\/p>\n<p>pdf = norm.pdf(x, loc=0, scale=1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u8ba1\u7b97\u4e86\u4ece-3\u52303\u4e4b\u95f4100\u4e2a\u70b9\u7684PDF\u503c\u3002<\/p>\n<\/p>\n<p><h2>3\u3001\u7d2f\u79ef\u5206\u5e03\u51fd\u6570<\/h2>\n<\/p>\n<p><p>\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528SciPy\u6765\u8ba1\u7b97\u7d2f\u79ef\u5206\u5e03\u51fd\u6570\uff08CDF\uff09\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u7d2f\u79ef\u5206\u5e03\u51fd\u6570<\/p>\n<p>cdf = norm.cdf(x, loc=0, scale=1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u8ba1\u7b97\u4e86\u4ece-3\u52303\u4e4b\u95f4100\u4e2a\u70b9\u7684CDF\u503c\u3002<\/p>\n<\/p>\n<h2><strong>\u4e09\u3001MATPLOTLIB\u7ed8\u5236\u6b63\u6001\u5206\u5e03<\/strong><\/h2>\n<p><p>Matplotlib\u662f\u4e00\u4e2a\u7528\u4e8e\u521b\u5efa\u9759\u6001\u3001\u52a8\u753b\u548c\u4ea4\u4e92\u5f0f\u53ef\u89c6\u5316\u7684Python 2D\u7ed8\u56fe\u5e93\u3002<\/p>\n<\/p>\n<p><h2>1\u3001\u7ed8\u5236\u76f4\u65b9\u56fe<\/h2>\n<\/p>\n<p><p>\u7ed8\u5236\u6b63\u6001\u5206\u5e03\u7684\u76f4\u65b9\u56fe\u662f\u6570\u636e\u53ef\u89c6\u5316\u7684\u4e00\u79cd\u5e38\u7528\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u7ed8\u5236\u76f4\u65b9\u56fe<\/strong><\/h2>\n<p>plt.hist(data, bins=30, density=True, alpha=0.6, color=&#39;g&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u4ee3\u7801\u5c06\u7ed8\u5236\u751f\u6210\u7684\u6b63\u6001\u5206\u5e03\u6570\u636e\u7684\u76f4\u65b9\u56fe\u3002<\/p>\n<\/p>\n<p><h2>2\u3001\u7ed8\u5236\u6982\u7387\u5bc6\u5ea6\u51fd\u6570<\/h2>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u597d\u5730\u7406\u89e3\u6570\u636e\uff0c\u53ef\u4ee5\u5728\u76f4\u65b9\u56fe\u4e0a\u7ed8\u5236PDF\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u6982\u7387\u5bc6\u5ea6\u51fd\u6570<\/p>\n<p>xmin, xmax = plt.xlim()<\/p>\n<p>x = np.linspace(xmin, xmax, 100)<\/p>\n<p>p = norm.pdf(x, loc=0, scale=1)<\/p>\n<p>plt.plot(x, p, &#39;k&#39;, linewidth=2)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b64\u4ee3\u7801\u5728\u76f4\u65b9\u56fe\u4e0a\u53e0\u52a0\u4e86PDF\u66f2\u7ebf\u3002<\/p>\n<\/p>\n<p><h2>3\u3001\u5b8c\u6574\u7684\u53ef\u89c6\u5316\u793a\u4f8b<\/h2>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7ed3\u5408\u76f4\u65b9\u56fe\u548cPDF\u7684\u5b8c\u6574\u53ef\u89c6\u5316\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>from scipy.stats import norm<\/p>\n<h2><strong>\u751f\u6210\u6b63\u6001\u5206\u5e03\u6570\u636e<\/strong><\/h2>\n<p>data = np.random.normal(loc=0, scale=1, size=1000)<\/p>\n<h2><strong>\u7ed8\u5236\u76f4\u65b9\u56fe<\/strong><\/h2>\n<p>plt.hist(data, bins=30, density=True, alpha=0.6, color=&#39;g&#39;)<\/p>\n<h2><strong>\u7ed8\u5236PDF<\/strong><\/h2>\n<p>xmin, xmax = plt.xlim()<\/p>\n<p>x = np.linspace(xmin, xmax, 100)<\/p>\n<p>p = norm.pdf(x, loc=0, scale=1)<\/p>\n<p>plt.plot(x, p, &#39;k&#39;, linewidth=2)<\/p>\n<p>plt.title(&quot;Histogram and PDF of Normal Distribution&quot;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b64\u793a\u4f8b\u751f\u62101000\u4e2a\u6b63\u6001\u5206\u5e03\u7684\u968f\u673a\u6570\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u76f4\u65b9\u56fe\u548cPDF\u66f2\u7ebf\u7684\u56fe\u5f62\u3002<\/p>\n<\/p>\n<h2><strong>\u56db\u3001\u5e94\u7528\u573a\u666f<\/strong><\/h2>\n<p><p>\u6b63\u6001\u5206\u5e03\u5728\u8bb8\u591a\u9886\u57df\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h2>1\u3001\u91d1\u878d\u9886\u57df<\/h2>\n<\/p>\n<p><p>\u5728\u91d1\u878d\u9886\u57df\uff0c\u8d44\u4ea7\u56de\u62a5\u901a\u5e38\u88ab\u5047\u8bbe\u4e3a\u6b63\u6001\u5206\u5e03\u3002\u901a\u8fc7\u6a21\u62df\u4e0d\u540c\u53c2\u6570\u7684\u6b63\u6001\u5206\u5e03\uff0c\u6295\u8d44\u8005\u53ef\u4ee5\u8bc4\u4f30\u4e0d\u540c\u6295\u8d44\u7ec4\u5408\u7684\u98ce\u9669\u548c\u56de\u62a5\u3002<\/p>\n<\/p>\n<p><h2>2\u3001\u81ea\u7136\u79d1\u5b66<\/h2>\n<\/p>\n<p><p>\u5728\u7269\u7406\u3001\u5316\u5b66\u548c\u751f\u7269\u5b66\u7b49\u81ea\u7136\u79d1\u5b66\u4e2d\uff0c\u8bb8\u591a\u81ea\u7136\u73b0\u8c61\u5982\u6d4b\u91cf\u8bef\u5dee\u3001\u81ea\u7136\u7279\u5f81\u7684\u5206\u5e03\u7b49\u90fd\u7b26\u5408\u6b63\u6001\u5206\u5e03\u3002<\/p>\n<\/p>\n<p><h2>3\u3001\u793e\u4f1a\u79d1\u5b66<\/h2>\n<\/p>\n<p><p>\u5728\u793e\u4f1a\u79d1\u5b66\u4e2d\uff0c\u6b63\u6001\u5206\u5e03\u7528\u4e8e\u63cf\u8ff0\u4eba\u53e3\u7279\u5f81\uff08\u5982\u8eab\u9ad8\u3001\u667a\u5546\u7b49\uff09\u7684\u5206\u5e03\u3002\u8fd9\u4e9b\u7279\u5f81\u901a\u5e38\u56f4\u7ed5\u4e00\u4e2a\u5e73\u5747\u503c\u5bf9\u79f0\u5206\u5e03\u3002<\/p>\n<\/p>\n<p><h2>4\u3001\u6570\u636e\u5206\u6790<\/h2>\n<\/p>\n<p><p>\u5728\u6570\u636e\u5206\u6790\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u4e2d\uff0c\u8bb8\u591a\u7b97\u6cd5\uff08\u5982\u9ad8\u65af\u6734\u7d20\u8d1d\u53f6\u65af\u5206\u7c7b\u5668\uff09\u5047\u8bbe\u6570\u636e\u7b26\u5408\u6b63\u6001\u5206\u5e03\u3002\u751f\u6210\u6b63\u6001\u5206\u5e03\u6570\u636e\u6709\u52a9\u4e8e\u6d4b\u8bd5\u8fd9\u4e9b\u7b97\u6cd5\u7684\u6027\u80fd\u3002<\/p>\n<\/p>\n<h2><strong>\u4e94\u3001\u603b\u7ed3<\/strong><\/h2>\n<p><p>\u751f\u6210\u6b63\u6001\u5206\u5e03\u662f\u6570\u636e\u5206\u6790\u548c\u79d1\u5b66\u8ba1\u7b97\u4e2d\u7684\u57fa\u672c\u4efb\u52a1\u3002<strong>\u4f7f\u7528Python\u4e2d\u7684NumPy\u3001SciPy\u548cMatplotlib\u5e93\uff0c\u53ef\u4ee5\u8f7b\u677e\u751f\u6210\u3001\u5206\u6790\u548c\u53ef\u89c6\u5316\u6b63\u6001\u5206\u5e03\u6570\u636e\u3002<\/strong> NumPy\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u968f\u673a\u6570\u751f\u6210\u65b9\u6cd5\uff0cSciPy\u63d0\u4f9b\u4e86\u9ad8\u7ea7\u7edf\u8ba1\u529f\u80fd\uff0c\u800cMatplotlib\u5219\u7528\u4e8e\u6570\u636e\u53ef\u89c6\u5316\u3002\u8fd9\u4e9b\u5de5\u5177\u7684\u7ed3\u5408\u4f7f\u5f97Python\u6210\u4e3a\u5904\u7406\u6b63\u6001\u5206\u5e03\u6570\u636e\u7684\u5f3a\u5927\u5e73\u53f0\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u751f\u6210\u6b63\u6001\u5206\u5e03\u7684\u6570\u636e\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u751f\u6210\u6b63\u6001\u5206\u5e03\u7684\u6570\u636e\u901a\u5e38\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u3002\u5177\u4f53\u65b9\u6cd5\u662f\u4f7f\u7528<code>numpy.random.normal<\/code>\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u5141\u8bb8\u7528\u6237\u6307\u5b9a\u5747\u503c\u3001\u6807\u51c6\u5dee\u4ee5\u53ca\u751f\u6210\u6570\u636e\u7684\u6837\u672c\u6570\u91cf\u3002\u4f8b\u5982\uff0c<code>numpy.random.normal(0, 1, 1000)<\/code>\u5c06\u751f\u62101000\u4e2a\u5747\u503c\u4e3a0\u3001\u6807\u51c6\u5dee\u4e3a1\u7684\u6b63\u6001\u5206\u5e03\u6570\u636e\u70b9\u3002<\/p>\n<p><strong>\u53ef\u4ee5\u4f7f\u7528\u54ea\u4e9b\u53ef\u89c6\u5316\u5de5\u5177\u6765\u5c55\u793a\u6b63\u6001\u5206\u5e03\uff1f<\/strong><br \/>\u4e3a\u4e86\u66f4\u597d\u5730\u5c55\u793a\u751f\u6210\u7684\u6b63\u6001\u5206\u5e03\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528Matplotlib\u5e93\u8fdb\u884c\u53ef\u89c6\u5316\u3002\u901a\u8fc7\u7ed8\u5236\u76f4\u65b9\u56fe\u548c\u6982\u7387\u5bc6\u5ea6\u51fd\u6570\uff08PDF\uff09\uff0c\u53ef\u4ee5\u6e05\u6670\u5730\u5c55\u793a\u6570\u636e\u7684\u5206\u5e03\u60c5\u51b5\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">import numpy as np\nimport matplotlib.pyplot as plt\n\ndata = np.random.normal(0, 1, 1000)\nplt.hist(data, bins=30, density=True, alpha=0.6, color=&#39;g&#39;)\nplt.show()\n<\/code><\/pre>\n<p><strong>\u5982\u4f55\u8c03\u6574\u6b63\u6001\u5206\u5e03\u7684\u53c2\u6570\u4ee5\u9002\u5e94\u7279\u5b9a\u9700\u6c42\uff1f<\/strong><br \/>\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539<code>numpy.random.normal<\/code>\u51fd\u6570\u7684\u53c2\u6570\u6765\u81ea\u5b9a\u4e49\u6b63\u6001\u5206\u5e03\u7684\u5f62\u72b6\u3002\u4f8b\u5982\uff0c\u8c03\u6574\u5747\u503c\u53c2\u6570\u53ef\u4ee5\u6539\u53d8\u5206\u5e03\u7684\u4e2d\u5fc3\u4f4d\u7f6e\uff0c\u800c\u8c03\u6574\u6807\u51c6\u5dee\u53c2\u6570\u53ef\u4ee5\u5f71\u54cd\u5206\u5e03\u7684\u5bbd\u5ea6\u3002\u901a\u8fc7\u8fd9\u4e9b\u53c2\u6570\uff0c\u7528\u6237\u53ef\u4ee5\u751f\u6210\u9002\u5408\u7279\u5b9a\u573a\u666f\u7684\u6570\u636e\u96c6\uff0c\u4f8b\u5982\u91d1\u878d\u6570\u636e\u6a21\u62df\u6216\u79d1\u5b66\u5b9e\u9a8c\u6570\u636e\u5206\u6790\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728Python\u4e2d\u751f\u6210\u6b63\u6001\u5206\u5e03\uff0c\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u7684numpy.random.normal()\u51fd\u6570\u3001SciP [&hellip;]","protected":false},"author":3,"featured_media":1015634,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1015630"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1015630"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1015630\/revisions"}],"predecessor-version":[{"id":1015638,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1015630\/revisions\/1015638"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1015634"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1015630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1015630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1015630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}