Poisson Distribution——泊松分布
老师留个小作业,用EXCEL做不同lambda(np)的泊松分布图,这里分别用EXCEL,Python,MATLAB和R简单画一下。
1. EXCEL
运用EXCEL统计学公式,POISSON,算出各个数据,作图。资料参考这里。
=POISSON.DIST(B$1,$A2,0)

注意这里绝对引用的方式,写完公式之后,直接上下左右拖动鼠标即可自动填充。之后插入图表。如下。

2.Python
这里stats.poisson.pmf中的pmf是probability mass function(概率质量函数)的缩写。
以下引自WIKI:
在概率论中,概率质量函数(probability mass function,简写为pmf)是离散随机变量在各特定取值上的概率。
概率质量函数和概率密度函数不同之处在于:概率质量函数是对离散随机变量定义的,本身代表该值的概率;
概率密度函数是对连续随机变量定义的,本身不是概率,只有对连续随机变量的概率密度函数在某区间内进行积分后才是概率。
import scipy.stats as stats
import matplotlib.pyplot as plt k = range(0,13)
for ld in range(7):
y = stats.poisson.pmf(k,ld)
plt.xlabel('K')
plt.ylabel('P')
plt.title('POISSON')
plt.plot(y,label=str(ld)) plt.legend()
plt.show()
输出图形:

3.MATLAB
x=0:12;
c = ['r','g','b','y','m','k'];
for i = (1:6)
y=poisspdf(x,i);
plot(x,y,c(i));
hold on
end
输出如下:

4.R
pmf <- function(lambda){
y = list()
for(k in 0:12){
y[k+1] <- round(dpois(x=k,lambda),3)
}
return(y)
}
mycols <- runif(10,min=1,max=length(colors()))
for(i in 1:6){
par(new=TRUE)
y = plot(c(0:12),pmf(i),type='l',ylim=c(0,0.4),col = mycols[i])
}
输出:

美中不足的是,楼主不知道如何为每条线设置标签。查了一下午legend函数,还是没搞定。。。
解决了回头补充吧。。。
###################################################
来补充了。。。问了问大佬们,给出下面的方法
pmf <- function(lambda){
y = list()
for(k in 0:12){
y[k+1] <- round(dpois(x=k,lambda),3)
}
y = unlist(y)
return(y)
}
mycols <- runif(10,min=1,max=length(colors()))
y_data <- matrix(unlist(lapply(1:6,FUN = pmf)),ncol = 6)
matplot(y_data,type='l',ylim=c(0,0.4),col = mycols)
colnames(y_data) = 1:ncol(y_data)
matplot(y_data,type='l',sub = "标记",ylim=c(0,0.4),col = mycols,main = "泊松分布图")
legend(
"topright"
,legend = colnames(y_data)
,text.col = mycols
,col = mycols
,lty = mycols
)
输出:

Poisson Distribution——泊松分布的更多相关文章
- Poisson distribution 泊松分布 指数分布
Poisson distribution - Wikipedia https://en.wikipedia.org/wiki/Poisson_distribution Jupyter Notebook ...
- 【概率论】5-4:泊松分布(The Poisson Distribution)
title: [概率论]5-4:泊松分布(The Poisson Distribution) categories: - Mathematic - Probability keywords: - Po ...
- [转]Poisson Distribution
Poisson Distribution Given a Poisson process, the probability of obtaining exactly successes in tria ...
- 基本概率分布Basic Concept of Probability Distributions 2: Poisson Distribution
PDF version PMF A discrete random variable $X$ is said to have a Poisson distribution with parameter ...
- NLP&数据挖掘基础知识
Basis(基础): SSE(Sum of Squared Error, 平方误差和) SAE(Sum of Absolute Error, 绝对误差和) SRE(Sum of Relative Er ...
- 常用的机器学习&数据挖掘知识点【转】
转自: [基础]常用的机器学习&数据挖掘知识点 Basis(基础): MSE(Mean Square Error 均方误差),LMS(LeastMean Square 最小均方),LSM(Le ...
- 【基础】常用的机器学习&数据挖掘知识点
Basis(基础): MSE(Mean Square Error 均方误差),LMS(LeastMean Square 最小均方),LSM(Least Square Methods 最小二乘法),ML ...
- R代码展示各种统计学分布 | 生物信息学举例
二项分布 | Binomial distribution 泊松分布 | Poisson Distribution 正态分布 | Normal Distribution | Gaussian distr ...
- 常用的机器学习&数据挖掘知识(点)总结
Basis(基础): MSE(Mean Square Error 均方误差), LMS(LeastMean Square 最小均方), LSM(Least Square Methods 最小二乘法), ...
随机推荐
- SharePoint 2013 一些小技巧
一.添加“SharePoint 2013 切换用户”标签 相比SharePoint 2010,SharePoint2013版本去掉了切换用户登陆的功能(如下图),其实这个可以通过改welcome.as ...
- 至强CPU性能排行,从X3210起,由低至高排列。
X3210X3220E5410E5506X5355X3320E5507X5365E5-2603E3-1220LE5-2403E5607X3330L5506X3230L5420E5-2407W3520E ...
- IntelliJ IDEA使用(2)——IDEA配置Tomcat
如果网上流传的方法(即方法2)不能配置成功,点击加号什么都没有的话,请看方法一配置方法. 解决问题:intlellij IDEA配置tomcat点击加号没东西. 方法一:手动添加tomcat插件然后再 ...
- 各种浏览器(IE,Firefox,Chrome,Opera)COOKIE修改方法[转]
各种浏览器(IE,Firefox,Chrome,Opera)COOKIE修改方法[转] 网站通过 Cookie 保存了我们访问网站的信息,在不同的浏览器中修改 Cookie 可以如下操作: Firef ...
- cubic-bezier贝塞尔曲线css3动画工具
今天在一本叫<HTML5触摸界面设计与开发>上看到一个做弹跳球的复杂动画效果,首先加速下降,停止,然后弹起时逐渐减速.是用cubic-bezier贝塞尔曲线来完成的.所以特地去学习了一下关 ...
- 用Python编写的第一个回测程序
用Python编写的第一个回测程序 2016-08-06 def savfig(figureObj, fn_prefix1='backtest8', fn_prefix2='_1_'): import ...
- myeclipse maven pom.xml 配置错误
http://www.oschina.net/question/2265006_219341#tags_nav maven pom.xml 配置文件错误 腾讯云消息队列CMQ架构解析> ...
- Retrofit 2.0使用(2)如何使用@Body的形式发送Post
在使用Retrofit的时候如果只是有几个参数我们可以用@Querry的形式,然后需要使用','隔开 但是在需要@Querry的参数多了之后,如果再用上面的方式就会造成参数写了一大堆的麻烦事 所以Re ...
- 0020 Linux 文件操作命令
1. 创建文件 touch 文件名 2. 删除文件 rm 文件名 3. 复制文件 cp 源文件 目录 4.剪切文件 mv 源文件 目标文件 5.重命名文件 mv 源文件名 新文件名 6.改变文件权限 ...
- MYSQL 基于GTID的复制
1.概述 从MYSQL5.6 开始,mysql开始支持GTID复制. 基于日志点复制的缺点: 从那个二进制日志的偏移量进行增量同步,如果指定错误会造成遗漏或者重复,导致数据不一致. 基于GTID复制: ...