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 最小二乘法), ...
随机推荐
- 关于css的一些知识点整理
一.标签的类型: 行内:span.a.b.i.strong.em. 1.共处一行 2.不支持设置宽高 display:block; 转换成块 块:h1-h6 p div ul ol 1. ...
- log4j日志不输出MyBatis SQL脚本?
日志输出级别调成debug,然并卵? 试试加下这个包. <dependency> <groupId>org.slf4j</groupId> <artifact ...
- mysql 插入中文报错: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value...
总结写在前面, 总结: 当Java通过jdbc链接mysql插入中文时,要保证程序可以正常执行,而且插入的中文不会乱码, mysql服务器端,对数据表(不是数据库)的编码设置,要保证是支持中文的,例如 ...
- javscript 中的术语和俚语
语言中俚语和方言.在JavaScript中也有一些俚语或者说是术语,看似奇淫巧技,还是有一些用处,有三种语言组件可以来构造术语:强转.逻辑运算符和位变换. 1.强转:在javascript和大部分的语 ...
- 【Unity基础知识之三】Unity Assets目录下的特殊文件夹名称
Unity3D的特殊目录名称 Unity预留了一些目录名称,这些目录有着特殊的含义.比较重要的有: Resources这个目录下的所有文件都会被打包到发布版本中,程序可以通过文件路径来访问它们.这 ...
- 《BI那点儿事》数据流转换——模糊分组转换
在模糊查找中我们提到脏数据是怎样进入到表中的事情,主要还是由于一些“Lazy-add”造成的.这种情况我们的肉眼很容易被欺骗,看上去是同一个单词,其实就差那么一个字母,变成了两个不同的单词.一个简单的 ...
- Android NDK开发入门实例
AndroidNDK是能使Android应用开发者把从c/c++编译而来的本地代码嵌入到应用包中的一系列工具的组合. 注意: AndroidNDK只能用于Android1.5及以上版本中. I. An ...
- php短路与 短路或
关于php短路的问题特性,三种写法的区别 $a = 1;$b=0;第一种: $a && $b = 'cccccccc';第二种 $a || $b = 'cccccccc';第三种 if ...
- 【ros】.bag文件
Bags are typically created by a tool like rosbag They store the serialized message data in a file as ...
- jq 实现发送验证码倒计时功能
var util = { wait:60, hsTime: function (that) { _this = this; if (_this.wait == 0) { $('#hsbtn').rem ...