当前位置:网站首页>Random distribution learning notes
Random distribution learning notes
2022-07-26 08:13:00 【Confused 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)
# Bernoulli distribution
# 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')
# The binomial distribution
# 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')
# Geometric distribution
# 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')
# Hypergeometric distribution
# 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')
# Poisson distribution
# 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')
# Normal distribution
# 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')
# Uniform distribution
# 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')
# An index distribution
# 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()边栏推荐
- Why is Google's internal tools not suitable for you?
- 2022/7/11 exam summary
- How WPS sets page headers page by page
- SPSS用KMeans、两阶段聚类、RFM模型在P2P网络金融研究借款人、出款人行为规律数据
- Introduction to arrays -- array
- Add traceid to the project log
- Burp Suite-第六章 如何使用Burp Spider
- Abstract classes and interfaces
- 一点一点理解微服务
- The difference between throw and throws?
猜你喜欢

CentOS install mysql5.7

一点一点理解微服务

Understand microservices bit by bit

JSP built-in object (implicit object) -- input / output object

2w字详解数据湖:概念、特征、架构与案例

苹果强硬新规:用第三方支付也要抽成,开发者亏大了!

美女裸聊一时爽,裸聊结束火葬场!

数组的介绍--Array

Idea settings set shortcut keys to convert English letters to case in strings

Unity metaverse (II), mixamo & animator hybrid tree and animation fusion
随机推荐
"Door lock" ignites a heated discussion on the safety of living alone. The new poster picture is suffocating
Burp Suite-第三章 如何使用Burp Suite代理
2W word detailed data Lake: concept, characteristics, architecture and cases
How WPS sets page headers page by page
On some concepts involved in journal papers compilation + journal query methods
Matlab-二/三维图上绘制黑点
Use js to count the number of occurrences of each string in the string array, and format it into an object array.
正则表达式作业
Implementation class under map interface
C# 获取选择文件信息
SPSS uses kmeans, two-stage clustering and RFM model to study the behavior law data of borrowers and lenders in P2P network finance
Burp Suite-第九章 如何使用Burp Repeater
基础乐理 节奏联系题,很重要
Differences and connections of previewkeydown, Keydown, keypress and Keyup in C WinForm
第四天作业
数组的介绍--Array
第三天作业
有点牛逼,一个月13万+
【 fastjson1.2.24反序列化漏洞原理代码分析】
One click deployment lamp and LNMP architecture