[Bayes] Hist & line: Reject Sampling and Importance Sampling
吻合度蛮高,但不光滑。

> L=
> K=/
> x=runif(L)
> ind=(runif(L)<(*x*(-x)^/K))
> hist(x[ind],probability=T,
+ xlab="x",ylab="Density",main="") /* 应用了平滑数据的核函数 */
> d=density(x[ind],from=,to=) // 只对标记为true的x做统计 --> 核密度估计
> lines(d,col=) // (BLUE)
> xx=seq(,,length=)
> lines(xx,*xx*(-xx)^,lwd=,col=) //lwd: line width, col: color number (Red)
API DOC: https://stat.ethz.ch/R-manual/R-devel/library/stats/html/density.html
参见:
http://blog.csdn.net/yuanxing14/article/details/41948485 基于核函数的目标跟踪算法 (貌似淘汰的技术)
https://www.zhihu.com/question/27301358/answer/105267357?from=profile_answer_card
Importance Sampling (Green line) 更为光滑:

> L=
> K=/
> x=runif(L)
> ind=(runif(L)<(*x*(-x)^/K))
> hist(x[ind],probability=T, xlab="x",ylab="Density",main="")
>
> d=density(x[ind],from=,to=)
> lines(d,col=)
>
> y=runif(L)
> w=*y*(-y)^3 // 可见,权重大小与实际分布吻合。
> W=w/sum(w) // 每个x轴的sample point的权重值W。
> d=density(y,weights=W,from=,to=)
> lines(d,col=)
>
> xx=seq(,,length=)
> lines(xx,*xx*(-xx)^,lwd=,col=)
无论是拒绝抽样还是重要性采样,都是属于独立采样,即样本与样本之间是独立无关的,这样的采样效率比较低,
如拒绝采样,所抽取的样本中有很大部分是无效的,这样效率就比较低,MCMC方法是关联采样,即下一个样本与这个样本有关系,从而使得采样效率高。
[Bayes] dchisq: Metropolis-Hastings Algorithm
[Bayes] Metroplis Algorithm --> Gibbs Sampling
[Bayes] Hist & line: Reject Sampling and Importance Sampling的更多相关文章
- PRML读书会第十一章 Sampling Methods(MCMC, Markov Chain Monte Carlo,细致平稳条件,Metropolis-Hastings,Gibbs Sampling,Slice Sampling,Hamiltonian MCMC)
主讲人 网络上的尼采 (新浪微博: @Nietzsche_复杂网络机器学习) 网络上的尼采(813394698) 9:05:00 今天的主要内容:Markov Chain Monte Carlo,M ...
- [Bayes] prod: M-H: Independence Sampler for Posterior Sampling
M-H是Metropolis抽样方法的扩展,扩展后可以支持不对称的提议分布. 对于M-H而言,根据候选分布g的不同选择,衍生出了集中不同的变种: (1)Metropolis抽样方法 (2)随机游动Me ...
- 蒙特卡洛法计算定积分—Importance Sampling
如上图所示,计算区间[a b]上f(x)的积分即求曲线与X轴围成红色区域的面积.下面使用蒙特卡洛法计算区间[2 3]上的定积分:∫(x2+4*x*sin(x))dx # -*- coding: u ...
- Implemented the “Importance Sampling of Reflections from Hair Fibers”
Just the indirect specular pass by importance sampling. With all layers. Manually traced by 3D Ham ...
- Importance sampling
用蒙特卡洛求解积分时 (Monte Carlo 随机采样对目标积分函数做近似) importance sampling func p(x) p(x)值大的地方,Monte Carlo多采几次 值小的地 ...
- Not All Samples Are Created Equal: Deep Learning with Importance Sampling
目录 概 主要内容 "代码" Katharopoulos A, Fleuret F. Not All Samples Are Created Equal: Deep Learnin ...
- Simple Random Sampling|representative sample|probability sampling|simple random sampling with replacement| simple random sampling without replacement|Random-Number Tables
1.2 Simple Random Sampling Census, :全部信息 Sampling: 抽样方式: representative sample:有偏向,研究者选择自己觉得有代表性的sam ...
- 转 如何理解 重要性采样(importance sampling)
分类: 我叫学术帖2011-03-25 13:22 3232人阅读 评论(4) 收藏 举报 图形 重要性采样是非常有意 思的一个方法.我们首先需要明确,这个方法是基于采样的,也就是基于所谓的蒙特卡洛法 ...
- SRS|Stratified sampling|系统抽样|Cluster sampling|multistage sampling|
生物统计学 总体和抽样 抽样方法: ========================================================= 简单随机抽样SRS:随机误差,系统误差 标准误, ...
随机推荐
- WCF、WebAPI、WCFREST和Web服务的差异 ASP.NETMVC和ASP.NETWebAPI的差异
WCF.WebAPI.WCFREST和Web服务的差异: Web服务 它是基于SOAP和XML的形式返回数据. 它仅支持HTTP协议. 它是开放源,但是不消耗任何客户端可以同时理解XML. 它可以仅在 ...
- RouterOS双线进行IP分流上网
环境: 1.第一条:电信静态IP,一级路由分配的IP:第二条:移动光纤 2.通过指定某些IP走电信,某些走移动 注意: 1.当有多条线路进行NAT伪装时,Out. Interface这个必须选择具体的 ...
- Mybatis 中遍历map 参数中的 list 和 array 属性
原文:https://blog.csdn.net/liudongdong0909/article/details/51048835 问题在项目有中遇到批量删除操作时,需要根据两个属性去删除数据,其中一 ...
- POJ 1595 素数打表水题
[题意简述]:给出N和C,让我们求出N以内的包含N的素数,然后依据若N以内的素数为奇数个,就将中间2*c-1个素数输出:若为偶数个.就将中间2*c个素数输出. [分析]:仅仅要题意理解就简单了. 详见 ...
- javax.crypto.BadPaddingException: Given final block not properly padded解决方案
解密的时候报错: javax.crypto.BadPaddingException: Given final block not properly padded 该异常是在解密 ...
- Comparison method violates its general contract 解决
java.lang.IllegalArgumentException: Comparison method violates its general contract! 原因 JDK7中的Collec ...
- Linux及Arm-Linux程序开发笔记(零基础入门篇)
Linux及Arm-Linux程序开发笔记(零基础入门篇) 作者:一点一滴的Beer http://beer.cnblogs.com/ 本文地址:http://www.cnblogs.com/bee ...
- 解决微信小程序ios端滚动卡顿的问题
方案1:直接使用微信小程序提供的 “scroll-view " 组件. <scroll-view scroll-y style="height: 100%;"> ...
- Mentor面向智能家居的IoT方案
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/wireless_com/article/details/82111734 眼下有各种智能家居的自己主 ...
- CDH:cdh5环境搭建
安装环境三台centos7 vmw: cdh- 192.168.0.141 [主节点] cdh- 192.168.0.142 [从节点] cdh- 192.168.0.143 [从节点] 1)[各节点 ...