老师留个小作业,用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——泊松分布的更多相关文章

  1. Poisson distribution 泊松分布 指数分布

    Poisson distribution - Wikipedia https://en.wikipedia.org/wiki/Poisson_distribution Jupyter Notebook ...

  2. 【概率论】5-4:泊松分布(The Poisson Distribution)

    title: [概率论]5-4:泊松分布(The Poisson Distribution) categories: - Mathematic - Probability keywords: - Po ...

  3. [转]Poisson Distribution

    Poisson Distribution Given a Poisson process, the probability of obtaining exactly successes in tria ...

  4. 基本概率分布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 ...

  5. NLP&数据挖掘基础知识

    Basis(基础): SSE(Sum of Squared Error, 平方误差和) SAE(Sum of Absolute Error, 绝对误差和) SRE(Sum of Relative Er ...

  6. 常用的机器学习&数据挖掘知识点【转】

    转自: [基础]常用的机器学习&数据挖掘知识点 Basis(基础): MSE(Mean Square Error 均方误差),LMS(LeastMean Square 最小均方),LSM(Le ...

  7. 【基础】常用的机器学习&数据挖掘知识点

    Basis(基础): MSE(Mean Square Error 均方误差),LMS(LeastMean Square 最小均方),LSM(Least Square Methods 最小二乘法),ML ...

  8. R代码展示各种统计学分布 | 生物信息学举例

    二项分布 | Binomial distribution 泊松分布 | Poisson Distribution 正态分布 | Normal Distribution | Gaussian distr ...

  9. 常用的机器学习&数据挖掘知识(点)总结

    Basis(基础): MSE(Mean Square Error 均方误差), LMS(LeastMean Square 最小均方), LSM(Least Square Methods 最小二乘法), ...

随机推荐

  1. websphere如何删除应用程序服务器(概要管理工具)

    在IBM WebSphere 的概要管理工具中我们可以新建一个应用程序服务器,但是工具中并未提供删除已经建过的应用程序服务器.下面 交大家一个比较简单的方法来删除应用程序服务器 图片中可以看到,我已经 ...

  2. Underscore.js 初探

    一. 简介   Underscore 这个单词的意思是“下划线”.   Underscore.js 是一个 JavaScript 工具库,提供了一整套的辅助方法供你使用.   Think that - ...

  3. [问题2014S10] 复旦高等代数II(13级)每周一题(第十教学周)

    [问题2014S10]  设 \(A,B\) 为 \(n\) 阶方阵, 证明: \(AB\) 与 \(BA\) 相似的充分必要条件是 \[\mathrm{rank}\big((AB)^i\big)=\ ...

  4. 我的android学习经历37

    android虚拟机没有键盘的问题,那是因为建立虚拟机的时候没有选择skin,重新编辑选择skin就可以了

  5. 史上最"恐怖"的12生肖图,绝对超猛

    史上最“恐怖”的十二生肖图,绝对超猛!图片依次是:鼠 牛 虎 兔 龙 蛇 马 羊 猴 鸡 狗 猪!

  6. 阻抗计算(用SI9000如何计算微带线)

    用SI9000如何计算微带线                一.几个概念: 阻抗的定义:在某一频率下,电子器件传输信号线中,相对某一参考层,其高频信号或电磁波在传播过程中所受的阻力称之为特性阻抗,它是 ...

  7. Trying to hack Redis via HTTP requests

    Trying to hack Redis via HTTP requests Context Imagine than you can access a Redis server via HTTP r ...

  8. Bilinear Filter

    参考资料: 1. 维基百科Biliner Filtering 2. 维基百科Texture Filtering 3.维基百科Bilinear Interpolation 4. 维基百科Bilinear ...

  9. jquery总结01-基本概念和选择器

    dom元素和jquery元素的区别 dom元素支持dom元素自带的属性和方法,jquery元素支持jquery元素自带的属性和方法 dom                  var div = doc ...

  10. java方法参数

    Java程序设计语言总是采用值调用.也就是说,方法得到的是所有参数的一个拷贝,特别是方法不能修改传递给它的任何参数变量的内容. 基本类型参数 1)X被初始化为percent值的一个拷贝: 2)X被乘以 ...