[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 ...
随机推荐
- Monte Carlo计算Pi,python实现
Monte Carlo import random import matplotlib.pyplot as plt import numpy as np 6 # 函数模拟点的随机掉落,并分为两组 de ...
- spring源码分析系列 (1) spring拓展接口BeanFactoryPostProcessor、BeanDefinitionRegistryPostProcessor
更多文章点击--spring源码分析系列 主要分析内容: 一.BeanFactoryPostProcessor.BeanDefinitionRegistryPostProcessor简述与demo示例 ...
- reveal 使用注意事项
**将libReveal.dylib 和 Reveal.framework 继承进项目后,一定要在 Build Phases->Link Binary With Libraries中将二者删除. ...
- Win7下MongoDB的安装和使用
Win7下MongoDB的安装和使用 1.下载: http://www.mongodb.org/downloads 2.安装: 安装目录为 D:\mongodb\MongoDB 2.6 Standar ...
- .NetCore中EFCore for MySql整理(三)之Pomelo.EntityFrameworkCore.MySql
一.Pomelo.EntityFrameworkCore.MySql简介 Git源代码地址:https://github.com/PomeloFoundation/Pomelo.EntityFrame ...
- SpringBootWEB项目和非Web项目的全局异常捕获
一.简介 SpringBoot的WEB异常捕获,如果是WEB项目的话,可以直接处理Controller中的异常.如果不是WEB项目的话,就需要使用AspectJ来做切面. 二.WEB项目 packag ...
- 树莓派中编译OpenCV3.4.1和OpenCvSharp
一.简介 本文重点描述在树莓派中编译OpenCV3.4.1和OpenCvSharp,大家都知道OpenCVSharp是使用C#调用OpenCV最简洁的一个库.但是在Linux上或者树莓派上运行时,需要 ...
- 【转】Vmware14安装Centos7无法上网问题的解决
原文链接 1. 选择Net模式 修改配置子网ip. 修改子网的IP不要和本机的IP地址在同一个网段 比如本机IP地址信息: 无线局域网适配器 WLAN: 连接特定的 DNS 后缀 . . . . . ...
- 安装nginx和添加ssl证书
一. 准备: 1. 需要有一台centos的服务器 2. 域名解析到服务器 3. 域名的nginx证书 二. 安装Nginx(输入下面的指令后:可访问实验机器外网 HTTP 服务http://118. ...
- 查看最新的Google地址
nslookup www.google.com 8.8.8.8