吻合度蛮高,但不光滑。

> 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的更多相关文章

  1. 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 ...

  2. [Bayes] prod: M-H: Independence Sampler for Posterior Sampling

    M-H是Metropolis抽样方法的扩展,扩展后可以支持不对称的提议分布. 对于M-H而言,根据候选分布g的不同选择,衍生出了集中不同的变种: (1)Metropolis抽样方法 (2)随机游动Me ...

  3. 蒙特卡洛法计算定积分—Importance Sampling

    如上图所示,计算区间[a  b]上f(x)的积分即求曲线与X轴围成红色区域的面积.下面使用蒙特卡洛法计算区间[2  3]上的定积分:∫(x2+4*x*sin(x))dx # -*- coding: u ...

  4. 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 ...

  5. Importance sampling

    用蒙特卡洛求解积分时 (Monte Carlo 随机采样对目标积分函数做近似) importance sampling func p(x) p(x)值大的地方,Monte Carlo多采几次 值小的地 ...

  6. Not All Samples Are Created Equal: Deep Learning with Importance Sampling

    目录 概 主要内容 "代码" Katharopoulos A, Fleuret F. Not All Samples Are Created Equal: Deep Learnin ...

  7. 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 ...

  8. 转 如何理解 重要性采样(importance sampling)

    分类: 我叫学术帖2011-03-25 13:22 3232人阅读 评论(4) 收藏 举报 图形 重要性采样是非常有意 思的一个方法.我们首先需要明确,这个方法是基于采样的,也就是基于所谓的蒙特卡洛法 ...

  9. SRS|Stratified sampling|系统抽样|Cluster sampling|multistage sampling|

    生物统计学 总体和抽样 抽样方法: ========================================================= 简单随机抽样SRS:随机误差,系统误差 标准误, ...

随机推荐

  1. java有时候String a="zz"出现String cannot be resolved to a variable

    原因很简单在String a="zz"前面有些该注释的没注释导致

  2. [Visual Studio] 自定义类模板

    1.找到vs2015/vs2012/vs2017的安装目录下:Common7\IDE\ItemTemplates\CSharp\Code\2052\Class 2.打开Class.cs文件 using ...

  3. 使用HttpClient请求,问题记录

    上篇博客说到使用单例HttpClient,以GET请求方法为例.可以看到对于Http请求头中Authorization参数,会根据传入的accessToken是否为空来判断是否添加此请求头. publ ...

  4. grep/pgrep/egrep/fgrep

    Differences between grep, pgrep, egrep, and fgrep (Linux): grep grep is an acronym that stands for & ...

  5. Axure RP Pro 7.0苏宁易购式标签切换效果教程

    转:http://jingyan.baidu.com/article/7082dc1c4f0a11e40a89bdac.html 页面标签切换效果,几乎是所有大网站(尤其是电商类网站)标配的交互方式: ...

  6. java实现在线浏览zip文件及文件下载

    应用背景:我们知道压缩文件中某一个文件的名字,只想下载这个文件而不下载整个压缩文件. 先来看一上QQ邮箱的附件浏览: 以下是我们第一个版本的: 业务逻辑中还要判读用户是否有此文件的防问权限 2017- ...

  7. quartus II输入原理图及仿真步骤

    在Quartus II中输入原理图以及实现仿真是学习基本数字电路的好方法.下面以一个基本的D锁存器为例,在quartus II 13.0中一步一步来实现原理图输入以及仿真过程. 1,创建工程 指定工程 ...

  8. [leetcode]Minimum Window Substring @ Python

    原题地址:https://oj.leetcode.com/problems/minimum-window-substring/ 题意: Given a string S and a string T, ...

  9. DNS的域名的解析解决办法(openDNS)

    http://www.williamlong.info/archives/1101.html

  10. [Java] LinkedHashMap 源码简要分析

    特点 * 各个元素不仅仅按照HashMap的结构存储,而且每个元素包含了before/after指针,通过一个头元素header,形成一个双向循环链表.使用循环链表,保存了元素插入的顺序. * 可设置 ...