# python随机模块22个函数详解（下）

12 uniform

random.uniform(10, 11)
10.789198208817488

13 triangular

data = [random.triangular(2,2,3) for i in range(20000)]
#直方图
plt.hist(data, bins=100,  color="#FF0000", alpha=.7)
#密度图
sns.kdeplot(data, shade=True,color="#FF0000")

14 vonmisesvariate

data = [random.vonmisesvariate(2,2) for i in range(20000)]
#直方图
plt.hist(data, bins=100,  color="#FF0000", alpha=.7)
#密度图
sns.kdeplot(data, shade=True,color="#FF0000")

15 weibullvariate

data = [random.weibullvariate(1,2) for i in range(20000)]
#直方图
plt.hist(data, bins=100,  color="#FF0000", alpha=.7)
sns.kdeplot(data, shade=True,color="#FF0000")

16 betavariate

data = [random.betavariate(1,2) for i in range(20000)]
#直方图
plt.hist(data, bins=100,  color="#FF0000", alpha=.7)
#密度图
sns.kdeplot(data, shade=True,color="#FF0000")

17 expovariate

data = [random.expovariate(2) for i in range(50000)]
#直方图
plt.hist(data, bins=100,  color="#FF0000", alpha=.7)
#密度图
sns.kdeplot(data, shade=True,color="#FF0000")

18 gammavariate

data = [random.gammavariate(2,2) for i in range(50000)]
#直方图
plt.hist(data, bins=100,  color="#FF0000", alpha=.7)
#密度图
sns.kdeplot(data, shade=True,color="#FF0000")

19 gauss

data = [random.gauss(2,2) for i in range(50000)]
#直方图
plt.hist(data, bins=100,  color="#FF0000", alpha=.7)
#密度图
sns.kdeplot(data, shade=True,color="#FF0000")

20 lognormvariate

data = [random.lognormvariate(4,2) for i in range(50000)]
#直方图
plt.hist(data, bins=100,  color="#FF0000", alpha=.7)
#密度图
sns.kdeplot(data, shade=True,color="#FF0000")

21 normalvariate

data = [random.normalvariate(2,4) for i in range(20000)]
#直方图
plt.hist(data, bins=100,  color="#FF0000", alpha=.7)
#密度图
sns.kdeplot(data, shade=True,color="#FF0000")

22 paretovariate

data = [random.paretovariate(4) for i in range(50000)]
#直方图
plt.hist(data, bins=100,  color="#FF0000", alpha=.7)
#密度图
sns.kdeplot(data, shade=True,color="#FF0000")

08-22 4万+

07-27 4322
01-08 679
10-17 239
10-16 341
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客