[Bayes] runif: Inversion Sampling
runifum
Inversion Sampling 看样子就是个路人甲。
Ref: [Bayes] Hist & line: Reject Sampling and Importance Sampling
> func=function(n) {
+ return(-0.5+sqrt(0.25+*runif(n)))
+ }
// 反函数的x的均匀sampling值 => y 就是原函数的x,刚好作为hist的输入参数
> hist(func(),probability=T, xlab=expression(theta), ylab="Density", main="Samples from f(x)")
// 以下是真实值,用线表示
> xx=seq(, , length=)
> lines(xx, xx+0.5, col=)
func=function(n) {
u=runif(n)
return(c(0.5*log(*u[u<0.5]),-0.5*log(*(-u[u>0.5]))) )
}
hist(func(),probability=T,xlab=expression(theta),ylab="Density",main="Samples from f(x)",nclass=,ylim=c(,))
xx=seq(-,,length=)
lines(xx,exp(-sign(xx)**xx),col=)
-sign(xx) 算是一个表达技巧,将原本两个半图,合并在了一起,如下:

简化技巧
Y = −λ log(1 − U ).
Note that if U is uniformly distributed on [0, 1], then 1 − U is also uniformly distributed on [0, 1] so that we could simply compute
Y = −λ log U
[Bayes] runif: Inversion Sampling的更多相关文章
- [Bayes] What is Sampling
Ref: http://blog.csdn.net/xianlingmao/article/details/7768833 通常,我们会遇到很多问题无法用分析的方法来求得精确解,例如由于式子特别,真的 ...
- [Bayes] dchisq: Metropolis-Hastings Algorithm
dchisq gives the density, # 计算出分布下某值处的密度值 pchisq gives the distribution fun ...
- [Bayes] MCMC (Markov Chain Monte Carlo)
不错的文章:LDA-math-MCMC 和 Gibbs Sampling 可作为精进MCMC抽样方法的学习材料. 简单概率分布的模拟 Box-Muller变换原理详解 本质上来说,计算机只能生产符合均 ...
- [AI] 深度数学 - Bayes
数学似宇宙,韭菜只关心其中实用的部分. scikit-learn (sklearn) 官方文档中文版 scikit-learn Machine Learning in Python 一个新颖的onli ...
- 本人AI知识体系导航 - AI menu
Relevant Readable Links Name Interesting topic Comment Edwin Chen 非参贝叶斯 徐亦达老板 Dirichlet Process 学习 ...
- [UFLDL] Generative Model
这一部分是个坑,应该对绝大多数菜鸡晕头转向的部分,因为有来自物理学界的问候. Deep learning:十九(RBM简单理解) Deep learning:十八(关于随机采样) 采样方法 [B ...
- [Bayes] Hist & line: Reject Sampling and Importance Sampling
吻合度蛮高,但不光滑. > L= > K=/ > x=runif(L) > *x*(-x)^/K)) > hist(x[ind],probability=T, + xla ...
- [Bayes] prod: M-H: Independence Sampler for Posterior Sampling
M-H是Metropolis抽样方法的扩展,扩展后可以支持不对称的提议分布. 对于M-H而言,根据候选分布g的不同选择,衍生出了集中不同的变种: (1)Metropolis抽样方法 (2)随机游动Me ...
- [Bayes] Parameter estimation by Sampling
虽然openBugs效果不错,但原理是什么呢?需要感性认识,才能得其精髓. Recall [Bayes] prod: M-H: Independence Sampler firstly. 采样法 Re ...
随机推荐
- Android Studio 使用过程遇到的坑
最近在尝试Android Studio打Jar的包,然而事实并不是想象的那么简单,so,写多个坑的解决,以备不时之需. 1.Error:Execution failed for task ':app: ...
- spring源码分析系列
spring源码分析系列 (1) spring拓展接口BeanFactoryPostProcessor.BeanDefinitionRegistryPostProcessor spring源码分析系列 ...
- 使用 ssmtp 於 shell 透過 Gmail 寄信
有很多程式於 bash shell 執行, 執行完要自動寄信出去, 但是最近都被 Google 退信, 最好的方法是透過 Gmail 直接寄信. 本來是要另外寫隻 script 來做這種事, 剛剛發現 ...
- Android 编程下 WebView 加载一个网页如何得到网页的 Cookie 值
http://www.cnblogs.com/sunzn/archive/2013/04/03/2998113.html mWebView.setWebViewClient(new MyWebView ...
- Asp.Net Core 自定义设置Http缓存处理
一.使用中间件 拦截请求自定义输出文件 输出前自定义指定响应头 public class OuterImgMiddleware { public static string RootPath { ge ...
- Nginx的安装和设置
Nginx是一个高性能的HTTP服务器和反向代理服务器.当一个服务器访问量太大时(比如C10k问题,Concurrent 10,000 Connection),就可以安装设置一个Nginx服务器,将客 ...
- ASIHttpRequest请求HTTPS
一种方法 ASIHTTPRequest *request = [ASIHTTPRequestrequestWithURL:[NSURLURLWithString:bodyString]]; [requ ...
- IDEA使用笔记(七)——编辑器最大个数的设置
我想一定有许多人和我一样在使用IDEA的时候,打开了许多的编辑器选项卡,但是打开的数量是有限的,我们想打开更多的页面,并且希望控制当再次达到大限的时候能关闭那些我们最久没有看的文件! 好吧!看下面的配 ...
- C#中DataTable删除多条数据
//一般情况下我们会这么删除 DataTable dt = new DataTable(); for (int i = 0; i < dt.Rows.Count; i++) { if (99 % ...
- OpenCV 学习笔记 04 深度估计与分割
本章节主要是使用深度摄像头的数据来识别前景区和背景区,这样就可以分别对前景和背景做不同的处理. 1 创建模块