gamma分布的density的奇怪特性,如下:


Poisson的Gamma先验

 h(x) 置信区间 的 获取

> n =
> sumx=
>
> alpha=
> beta=0.01
> pmean=(alpha+sumx)/(beta+n)
> L=qgamma(0.025, alpha+sumx, beta+n)  // 获得cdf的边界
> U=qgamma(0.975, alpha+sumx, beta+n)
>
> cat("Posterior mean: ", pmean, " (", L, ",",U,")")
Posterior mean: 382.8796 ( 378.1376 , 387.6506 )
// 95% 置信区间的边界值 还有期望。

Monte Carlo sampling:

N= # or 500 or 5000
L=U=rep(NA,length=)
for (i in :) {
dat=sort(rgamma(N,alpha+sumx,beta+n))
L[i]=dat[0.025*N]
U[i]=dat[0.975*N]
} // 获得某分位点的大量样本
widthL=max(L)-min(L)
widthU=max(U)-min(U)
par(mfrow=c(,))
hist(L,probability=T,xlab="Lower 95% CI bound")
points(qgamma(0.025,alpha+sumx,beta+n),,pch=,col=)
hist(U,probability=T,xlab="Upper 95% CI bound")
points(qgamma(0.975,alpha+sumx,beta+n),,pch=,col=)
cat("L interval variability (range):",widthL,"\n")
cat("U interval variability (range):",widthU,"\n")

Sampling估计的分位点,看来与True value差不多呢。

> mean(L)
[] 378.0747
> mean(U)
[] 387.5853

问题来了,N要多大才能保证要求的分位点估计精度:Sol 要 according to Central Limit Thearem.

 p(y) 的预测

alpha=; beta=0.01
sumx=; n=65 theta=rgamma(,alpha+sumx,beta+n)  // 后验sita
y=rpois(,theta)  // poisson分布sampling,带入后验sita的f(y|sita),5000个相应的预测值
hist(y,probability=T,ylab="Density",main="Posterior predictive distribution")
// sampling法得到直方图。
// 相当吻合!
// 精确函数得到散点图。
xx=:
pr
=dnbinom(xx,sumx+alpha,-/(beta+n+))
#lines(xx,pr,col=) # The (incorrect) continuous version - ok as an approx.
#The (correct) discrete version:
for (i in :length(xx)) {
  lines(c(xx[i],xx[i+]),rep(pr[i],),col=,lwd=)
}

[Bayes] qgamma & rgamma: Central Credible Interval的更多相关文章

  1. [AI] 深度数学 - Bayes

    数学似宇宙,韭菜只关心其中实用的部分. scikit-learn (sklearn) 官方文档中文版 scikit-learn Machine Learning in Python 一个新颖的onli ...

  2. 本人AI知识体系导航 - AI menu

    Relevant Readable Links Name Interesting topic Comment Edwin Chen 非参贝叶斯   徐亦达老板 Dirichlet Process 学习 ...

  3. (main)贝叶斯统计 | 贝叶斯定理 | 贝叶斯推断 | 贝叶斯线性回归 | Bayes' Theorem

    2019年08月31日更新 看了一篇发在NM上的文章才又明白了贝叶斯方法的重要性和普适性,结合目前最火的DL,会有意想不到的结果. 目前一些最直觉性的理解: 概率的核心就是可能性空间一定,三体世界不会 ...

  4. Simulation of empirical Bayesian methods (using baseball statistics)

    Previously in this series: The beta distribution Empirical Bayes estimation Credible intervals The B ...

  5. BAYESIAN STATISTICS AND CLINICAL TRIAL CONCLUSIONS: WHY THE OPTIMSE STUDY SHOULD BE CONSIDERED POSITIVE(转)

    Statistical approaches to randomised controlled trial analysis The statistical approach used in the ...

  6. R语言缺点

    R的优点:免费,开源,体积小.缺点:对大文本处理差,另外一个也在于开源,package如果出错,烦死你.当你跑比较大的simulation,对效率有要求的时候,有时还是不得不用C,这可能是10小时和1 ...

  7. 疫情期,如何用A/B测试快速迭代你的产品?

    作者:友盟+数据科学家 杨玉莲.陆子骏 冠状病毒来袭牵动着每个人的心,但是病毒影响的不仅仅是我们的健康,也以极快的速度极深远地影响了整个移动互联网的发展.主流阵地原本在线下的需求,如医疗和生鲜电商,快 ...

  8. maven 下载jar失败: resolution will not be reattempted until the update interval of central has elapsed or updates are forced

    Multiple annotations found at this line: - ArtifactTransferException: Failure to transfer com.faster ...

  9. maven执行报错resolution will not be reattempted until the update interval of nexus h

    maven在执行过程中抛错: 引用 ... was cached in the local repository, resolution will not be reattempted until t ...

随机推荐

  1. C++有关 const & 内敛 & 友元&静态成员那些事

    C++中有关 const & 内敛 & 友元&静态成员 的用法比较杂乱,算是C++中一个麻烦的部分.现速速的对它们做大致的总结,了解它们当中常见的用法和陷阱. const修饰的 ...

  2. 【2013Esri全球用户大会精彩案例】GIS for Philadelphia’s Finest --费城警用GIS

     行业领域:警务   拥有6000多警员和侦探的费城警察局,历时三年,搭建了费城警用GIS,目前可以对每天发生的事进行汇总(如图1),并可动态的进行热点分析(如图2).区域指挥官可方便的查看警员的活动 ...

  3. python 廖雪峰的官方网站

    https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014316119884678 ...

  4. android:四种基本布局

    一个丰富的界面总是要由很多个控件组成的,那我们如何才能让各个控件都有条不紊地 摆放在界面上,而不是乱糟糟的呢?这就需要借助布局来实现了.布局是一种可用于放置很 多控件的容器,它可以按照一定的规律调整内 ...

  5. python测试开发django-49.allow_tags和mark_safe

    前言 前面一篇使用allow_tags方法可以在xadmin的后台页面中插入html代码,在2.x版本ModelAdmin里面删除了allow_tags属性的支持,使用mark_safe函数代替 al ...

  6. 递归与迭代的联系以及优缺点(以c++为例)

    1.递归的定义: 程序直接或间接的调用自身的方法. 递归算法的特点:(1) 递归就是在过程或函数里调用自身.(2) 在使用递归策略时,必须有一个明确的递归结束条件,称为递归出口.(3) 递归算法解题通 ...

  7. MSVC 12: compiler error in boost/type_traits/common_type.hpp

    来自: https://svn.boost.org/trac10/ticket/11885 MSVC 12: compiler error in boost/type_traits/common_ty ...

  8. Oracle 12c RMAN备份文档

    创建备份目录,查看剩余空间 [cistest@cistest ~]$ df -h df: '/home/oratest/.gvfs': Permission denied Filesystem Siz ...

  9. Elasticsearch 开启

    一.知识补充,摘抄,总结 1. Elasticsearch ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.E ...

  10. 微信支付(APP支付)-服务端开发(一)

    微信支付,首先需要注册一个商户平台公众账号,(网址:https://pay.weixin.qq.com/index.php/home/d_login) 目前微信支付的接入方式有四种方式:公众号支付,A ...