常见六种随机变量分布可视化
小树叶简谱
from scipy.stats import binom
import matplotlib.pyplot as plt
import numpy as np
n = 10lacks
dnf90版本p = 0.3
k = np.arange(0, 10)
binomial = binom.pmf(k, n, p)
plt.plot(k, binomial)
plt.title('Binomial: n = %i, p=%0.2f' % (n, p), fontsize=15)plt.xlabel('Number of success')
台儿庄古城简介plt.ylabel('Probability of sucess', fontsize=15)
plt.show()
六爻卦六十四卦详解
dis_2 = np.random.binomial(10,0.5,size=10000)plt.hist(dis_2,bins=10,color='r',alpha=0.4,edgecolor='y')
plt.show()
打印机驱动卸载dis_3 = np.random.poisson(8,100000)
# lam 随机事件发⽣率,size 形状 n * p = 8
plt.hist(dis_3,bins=8,color='r',alpha=0.4,edgecolor='y')plt.show()
一叶知心
1.1 离散型随机变量-(伯努利分布):1.2 离散型随机变量-(⼆项分布):1.3 离散型随机变量-(泊松分布):
dis_4 = al(0,1,100000)
plt.hist(dis_4,bins=800,color='r',alpha=0.4,edgecolor='y')
plt.show()
dis_5 = ponential(0.125,100000)
plt.hist(dis_5,bins=6000,color='r',alpha=0.4,edgecolor='y')
1.4 连续型随机变量-(正态分布):1.5 连续型随机变量-(指数分布):1.6 连续型随机变量-(拉普拉斯分布):
import numpy as np
laplace1 = np.random.laplace(0, 1, 10000)
表达母爱的古诗
laplace2 = np.random.laplace(0, 2, 10000)
import matplotlib.pyplot as plt
fig, (ax1, ax2) = plt.subplots(1,2, sharex=True, sharey=True) ax1.hist(laplace1,bins=1000, label="lambda:1")
ax1.legend()
ax2.hist(laplace2, bins=1000, label="lambda:2")
ax2.legend()
plt.show()