小编Kar*_*are的帖子

隐藏直方图

因此,我想绘制正态分布,并且我已经看到一种实现此目的的方法是使用以下代码:

import numpy as np
import matplotlib.pyplot as plt

mu = 5
sigma = 1

s = np.random.normal(mu, sigma, 1000)

count, bins, ignored = plt.hist(s, 100, normed=True);
pdf = 1/(sigma * np.sqrt(2 * np.pi)) * np.exp(- (bins - mu)**2 / (2 * sigma**2))

mu_ = 10
sigma_ = 1
s = np.random.normal(mu_, sigma_, 1000)

count_, bins_, ignored_ = plt.hist(s, 100, normed=True);
pdf_ = 1/(sigma_ * np.sqrt(2 * np.pi)) * np.exp(- (bins_ - mu_)**2 / (2 * sigma_**2))

plt.plot(bins, pdf, linewidth=2, …
Run Code Online (Sandbox Code Playgroud)

python plot matplotlib histogram

5
推荐指数
2
解决办法
3900
查看次数

标签 统计

histogram ×1

matplotlib ×1

plot ×1

python ×1