当前位置:网站首页>随机分布学习笔记
随机分布学习笔记
2022-07-26 08:10:00 【浑浑噩噩666】
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
def plot(x, y, *args):
ax, title, xlabel, ylabel, legend = args
ax.set_title(title)
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
ax.set_xlim(x[0]-0.05,x[-1]+0.05)
ax.set_ylim(-0.05,1.05)
ax.plot(x,y,'.')
ax.legend([legend],loc='upper right')
fig, axes = plt.subplots(8,2)
# 伯努利分布
# print(stats.bernoulli.rvs(p=0.5,size=10))
x = np.arange(2)
plot(x,stats.bernoulli.pmf(k=x,p=0.8),axes[0,0],'bernoulli', 'k', 'p', 'pmf')
plot(x,stats.bernoulli.cdf(k=x,p=0.8),axes[0,1],'bernoulli', 'k', 'p', 'cdf')
# 二项分布
# print(stats.binom.rvs(n=10,p=0.5,size=10))
x = np.arange(20)
plot(x,stats.binom.pmf(k=x,n=10,p=0.5),axes[1,0],'binom', 'k', 'p', 'pmf')
plot(x,stats.binom.cdf(k=x,n=10,p=0.5),axes[1,1],'binom', 'k', 'p', 'cdf')
# 几何分布
# print(stats.geom.rvs(p=0.5,size=10))
x = np.arange(20)
plot(x,stats.geom.pmf(k=x,p=0.5),axes[2,0],'geom', 'k', 'p', 'pmf')
plot(x,stats.geom.cdf(k=x,p=0.5),axes[2,1],'geom', 'k', 'p', 'cdf')
# 超几何分布
# print(stats.hypergeom.rvs(M=10,n=4,N=6,size=10))
x = np.arange(20)
plot(x,stats.hypergeom.pmf(k=x,M=10,n=4,N=6),axes[3,0],'hypergeom', 'k', 'p', 'pmf')
plot(x,stats.hypergeom.cdf(k=x,M=10,n=4,N=6),axes[3,1],'hypergeom', 'k', 'p', 'cdf')
# 泊松分布
# print(stats.poisson.rvs(mu=5,size=10))
x = np.arange(20)
plot(x,stats.poisson.pmf(k=x,mu=5),axes[4,0],'poisson', 'k', 'p', 'pmf')
plot(x,stats.poisson.cdf(k=x,mu=5),axes[4,1],'poisson', 'k', 'p', 'cdf')
# 正态分布
# print(stats.norm.rvs(loc=0,scale=1,size=10))
x = np.linspace(-10, 10, num=100)
plot(x,stats.norm.pdf(x=x,loc=0,scale=1),axes[5,0],'norm', 'k', 'p', 'pdf')
plot(x,stats.norm.cdf(x=x,loc=0,scale=1),axes[5,1],'norm', 'k', 'p', 'cdf')
# 均匀分布
# print(stats.uniform.rvs(loc=0,scale=1,size=10))
x = np.linspace(0, 1, num=100)
plot(x,stats.uniform.pdf(x=x,loc=0,scale=1),axes[6,0],'uniform', 'k', 'p', 'pdf')
plot(x,stats.uniform.cdf(x=x,loc=0,scale=1),axes[6,1],'uniform', 'k', 'p', 'cdf')
# 指数分布
# print(stats.expon.rvs(scale=2,size=10))
x = np.linspace(0, 10, num=100)
plot(x,stats.expon.pdf(x=x,scale=2),axes[7,0],'expon', 'k', 'p', 'pdf')
plot(x,stats.expon.cdf(x=x,scale=2),axes[7,1],'expon', 'k', 'p', 'cdf')
plt.show()边栏推荐
- JSP built-in object (implicit object)
- 一点一点理解微服务
- Reading and writing properties file
- Lnmp+wordpress to quickly build a personal website
- Use of views
- 利用js实现统计字符串数组中各字符串出现的次数,并将其格式化为对象数组。
- NFS service and Samba service deployment
- 一文掌握mysql数据库审计特点、实现方案及审计插件部署教程
- The most complete network: detailed explanation of six constraints of MySQL
- Burp Suite-第二章 Burp Suite代理和浏览器设置
猜你喜欢

利用js实现统计字符串数组中各字符串出现的次数,并将其格式化为对象数组。

An empirical study on urban unemployment in Guangxi (Macroeconomics)

The first ide overlord in the universe, replaced...

JSP implicit object -- scope

Burp Suite-第一章 Burp Suite 安装和环境配置

Understand microservices bit by bit

要不你给我说说什么是长轮询吧?

FTP service

我,35岁了。

Stack simulation queue
随机推荐
Burp Suite-第九章 如何使用Burp Repeater
Excel file reading and writing (creation and parsing)
The difference between overloading and rewriting
A tutorial for mastering MySQL database audit characteristics, implementation scheme and audit plug-in deployment
Distributed system and distributed database system (Introduction)
2022-07-13 group 5 Gu Xiangquan's learning notes day06
Summarize the common high-frequency interview questions of the software testing post
Summary of distributed related interview questions
JSP built-in object (implicit object) -- input / output object
JSP implicit object servlet object
Why don't you tell me what long polling is?
Burp Suite - Chapter 2 burp suite proxy and browser settings
What are the differences between FileInputStream and bufferedinputstream?
Sort sort IP addresses
外卖小哥,才是这个社会最大的托底
2022 / 7 / 16 exam summary
2022/7/1
数组的介绍--Array
Burp suite Chapter 8 how to use burp intruder
MySQL implementation plan