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. 107. 二叉树的层次遍历 II

    107. 二叉树的层次遍历 II 题意 给定一个二叉树,返回其节点值自底向上的层次遍历. (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历). 解题思路 递归:利用前序遍历的思想,在递归过程中 ...

  2. memcache bug

    用memcached有时会报错  the lowest two bytes of the flags array is reserved for pecl/memcache 将以前的 $mc-> ...

  3. Android Binder学习的网站

    1. Binder系列 http://gityuan.com/2015/10/31/binder-prepare/ 2. Binder机制 http://jcodecraeer.com/a/anzhu ...

  4. linux常用服务程序一键安装

    PHP7安装 rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm service php-fpm stop yum remove php5* ...

  5. SourceTree + Beynod Compare解决Git冲突的方法

    https://www.cnblogs.com/yufeng218/p/6523422.html

  6. Winform自动更新组件分享

    作者:圣殿骑士 出处:http://www.cnblogs.com/KnightsWarrior/ 关于作者:专注于微软平台项目架构.管理和企业解决方案.自认在面向对象及面向服务领域有一定的造诣,熟悉 ...

  7. Bootstrap 标签页(Tab)插件

    摘自: http://www.runoob.com/bootstrap/bootstrap-tab-plugin.html Bootstrap 标签页(Tab)插件 标签页(Tab)在 Bootstr ...

  8. [Mockito] Mock List interface

    In this post, we are going to see more functionalities in Mockito. Mock a List interface: @Test publ ...

  9. 【T01】理解面向连接和无连接协议之间的区别

    1.面向连接和无连接指的是协议,本质区别在于:对于无连接协议来说,每个分组的处理都独立于其他的分组. 而对于面向连接的协议,协议实现维护了当前分组与后继分组有关的状态信息. 2.无连接就是指udp,分 ...

  10. CSS中的偏僻知识点

    一.css中的calc 在CSS中有calc属性用于尺寸的计算,可以让百分比和像素值进行运算. div {width : calc(100% - 30px);} 为了兼容性 /*Firefox*/ - ...