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

Unity metaverse (II), mixamo & animator hybrid tree and animation fusion

全网最全:Mysql六种约束详解

The most complete network: detailed explanation of six constraints of MySQL

How WPS sets page headers page by page

有点牛逼,一个月13万+

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

Ten thousand words long article | deeply understand the architecture principle of openfeign

基础乐理 节奏联系题,很重要

Strtus2历史漏洞复现

Burp Suite-第三章 如何使用Burp Suite代理
随机推荐
Implementation class under map interface
vscode国内的镜像服务器加速
通用 DAO 接口设计
C # get the information of the selected file
Copy pcap file with producer consumer model
Burp suite Chapter 5 how to use burp target
The bigger the project is, the bigger it is. This is how I split it
有点牛逼,一个月13万+
Excel file parsing
[xshell7 free download and installation]
The most complete network: detailed explanation of six constraints of MySQL
If the thread crashes, why doesn't it cause the JVM to crash? What about the main thread?
Burp Suite-第五章 如何使用Burp Target
正则表达式作业
Spotty music data client_ ID account
2022/7/12 exam summary
给项目日志加上traceid
Exam summary on July 15, 2022
What are the differences between FileInputStream and bufferedinputstream?
Software engineering -- dental clinic -- demand analysis