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 最小二乘法), ...
随机推荐
- Java 基础知识 练习
1.在DOS命令下输入:java Hello出现以下结果:Bad command or the file name可能是什么原因? (错误的命令或文件名) 输入的命令不存在,或者不在指定的路径中 2. ...
- Robotlegs框架1.5简介
该框架的1.5版本位于https://github.com/robotlegs/robotlegs-framework/tree/version1,现在已经出了重新架构的2.0版本,所以我决定先研究已 ...
- 【20160924】GOCVHelper 图像处理部分(2)
//根据轮廓的面积大小进行选择 vector<VP> selectShapeArea(Mat src,Mat& draw,vector<VP> contour ...
- EntityFramework Core 学习笔记 —— 创建模型
原文地址:https://docs.efproject.net/en/latest/modeling/index.html 前言: EntityFramework 使用一系列的约定来从我们的实体类细节 ...
- Android first---文件读取(登录案例编写为主)
以android登录案例来介绍文件的读取与androidAPI给予的方法 第一步:绘制界面 绘制方法:在线性布局下面设置相对布局 代码部分: <LinearLayout xmlns:androi ...
- Ubuntu安装R及RStudio
-------------------------------------------------------------- 自学记录,交流请发送邮件至gxz1984@gmail.com ------ ...
- [问题2014A11] 解答
[问题2014A11] 解答 我们需要利用以下关于幂等阵判定的结论,它是复旦高代书第 142 页的例 3.6.4: 结论 设 \(A\) 为 \(n\) 阶方阵, 则 \(A^2=A\) 当且仅当 ...
- JS中的各种类型转换规则(转)
JS中的类型转换非常恶心,大家都懂的,不过该学还是要学. 今天看犀牛书看到了转换规则,总结出来. X转字符串.数字.布尔值 X表示各种类型的值,直接上图: 值 转数字 转字符串 转布尔值 undefi ...
- 如何管理linux开机自启服务
如何管理linux开机自启服务? 自启动服务非常重要,例如 (1)需要手动添加希望自启的服务,如安装svn后没有自动添加,就需要我们手动加入(2)安装某些程序后,自动加到自启动了,但我们不需要,需要手 ...
- 20161026__Oracle10g_DataGuard
1. orcl.__db_cache_size=180355072 orcl.__java_pool_size=4194304 orcl.__large_pool_size=4194304 orcl. ...