当前位置:网站首页>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()边栏推荐
猜你喜欢

OSPF总结
![[endnote] detailed explanation of document template layout syntax](/img/fd/2caf4ff846626411fe8468f870e66a.png)
[endnote] detailed explanation of document template layout syntax

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

Burp Suite-第三章 如何使用Burp Suite代理

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

关于期刊论文所涉及的一些概念汇编+期刊查询方法

一键部署LAMP和LNMP架构

Recurrence of strtus2 historical vulnerability

On some concepts involved in journal papers compilation + journal query methods

Dev gridcontrol 捕获按键事件
随机推荐
mysql函数汇总之日期和时间函数
Sort sort IP addresses
BGP --- 边界网关协议
Web side 3D visualization engine hoops communicator reads 10g super large model test | digital twin Technology
2022-07-08 group 5 Gu Xiangquan's learning notes day01
Ten thousand words long article | deeply understand the architecture principle of openfeign
Stack simulation queue
Abstract classes and interfaces
Oracle 常用函数
Read and write of zip file
2022/7/17 exam summary
C# WinForm中PreviewKeyDown、KeyDown、KeyPress、KeyUp区别与联系
C# 获取选择文件信息
BGP的基本配置
2022-07-09 group 5 Gu Xiangquan's learning notes day02
2w字详解数据湖:概念、特征、架构与案例
General Dao interface design
2022/7/12 exam summary
Introduction to arrays -- array
Exam summary on June 27, 2022