当前位置:网站首页>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()边栏推荐
- 2022/7/1
- Differences and connections of previewkeydown, Keydown, keypress and Keyup in C WinForm
- The difference between equals() and = =
- The idea of stack simulating queue
- The first ide overlord in the universe, replaced...
- 第四天作业
- [endnote] detailed explanation of document template layout syntax
- Strtus2历史漏洞复现
- 咱就是来聊聊并发编程的三大核心问题。
- Software engineering -- dental clinic -- demand analysis
猜你喜欢

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

Let's talk about the three core issues of concurrent programming.

咱就是来聊聊并发编程的三大核心问题。

How to determine the authenticity of the website you visit -- certificate system
分享高压超低噪声LDO测试结果(High Voltage Ultra-low Noise LDO)

Burp Suite-第四章 SSL和Proxy高级选项

File parsing (JSON parsing)

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

一键部署LAMP和LNMP架构

Burp suite Chapter 6 how to use burp spider
随机推荐
Stack simulation queue
Template summary
【EndNote】文献类型与文献类型缩写汇编
关于期刊论文所涉及的一些概念汇编+期刊查询方法
Matlab-二/三维图上绘制黑点
Function default parameters, arrow functions, and remaining parameters in ES6 - explanation
Common methods of string: construction method, other methods
[endnote] compilation of document types and abbreviations of document types
我,35岁了。
A tutorial for mastering MySQL database audit characteristics, implementation scheme and audit plug-in deployment
The difference between overloading and rewriting
[June 29, 2022] examination summary
Burp suite Chapter 3 how to use burp suite agent
给项目日志加上traceid
美女裸聊一时爽,裸聊结束火葬场!
Zroi easy sum (generating function, block, DP, combination, polynomial)
2022/7/12 exam summary
Summary of traversal methods of list, set, map, queue, deque and stack
通用 DAO 接口设计
2022/7/7 exam summary