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. spring boot + embed tomcat + standalone jar的内存泄露问题

    前一阵遇到了一个很坑的内存泄露问题,记录于此: 有个项目采用spring cloud重构后,部署到线上(其中有一个接口,大概每天调用量在1千万次左右),发现zabbix监控里,linux的可用内存一直 ...

  2. Microsoft.mshtml.dll 添加引用及类型选择错误问题解决办法

    在比较早的文章中,提到使用 Microsoft.mshtml.dll 进行模拟浏览器点击的例子. 1.添加引用的问题 一般在开发环境下会在三个地方存有microsoft.mshtml.dll文件.所以 ...

  3. 实战:mysql统计指定架构的全部表的数据和索引大小情况-v2

    PS:第一个版本号里未做输入的schema_name和table_name推断,改动了一下!再次share! #统计指定架构的全部表的数据和索引大小情况 #tablesize.sh #!/bin/sh ...

  4. windows 启动关闭Oracle监听和服务

    经常要用数据库,让他自己启动的话,开机太慢,所以用命令启动方便点.    1.开启:     在运行中输入cmd,进入控制台,lsnrctl start回车,提示启动监听成功后 net start O ...

  5. java类型生命周期

    开始阶段 装载:把二进制形式的java类型读入jvm中. 1)通过该类型的完全限定名,产生一个代表该类型的二进制数据流:2)解析这个二进制数据流为方法区内的内部数据结构:3)创建一个表示该类型的jav ...

  6. MDX Step by Step 读书笔记(七) - Performing Aggregation 聚合函数之 Sum, Aggregate, Avg

    开篇介绍 SSAS 分析服务中记录了大量的聚合值,这些聚合值在 Cube 中实际上指的就是度量值.一个给定的度量值可能聚合了来自事实表中上千上万甚至百万条数据,因此在设计阶段我们所能看到的度量实际上就 ...

  7. ionic tab显示到顶部去了

    添加配置调整显示位置 .config(function($stateProvider, $urlRouterProvider,$ionicConfigProvider) { $ionicConfigP ...

  8. python3用BeautifulSoup抓取id='xiaodeng',且正则包含‘elsie’的标签

    # -*- coding:utf-8 -*- #python 2.7 #XiaoDeng #http://tieba.baidu.com/p/2460150866 #使用多个指定名字的参数可以同时过滤 ...

  9. shell脚本死循环检查是否有特定的路由,若存在进行删除操作

    while [ 1 ] do tun0_route=`ip route |grep -ci "100.100.80.0"` if [ $tun0_route -eq 0 ];the ...

  10. Easyui-DataGrid 分页多选框 及 遍历所有选中项

    html <table id='grid' class='easyui-datagrid' style='height:500px' url='Ajax-index.php?module=< ...