[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:随机误差,系统误差 标准误, ...
随机推荐
- Java中的ReentrantLock和synchronized两种锁定
原文:http://www.ibm.com/developerworks/cn/java/j-jtp10264/index.html 多线程和并发性并不是什么新内容,但是 Java 语言设计中的创新之 ...
- Android Gesture Detector
Android Touch Screen 与传统Click Touch Screen不同,会有一些手势(Gesture),例如Fling,Scroll等等.这些Gesture会使用户体验大大提升.An ...
- vmware虚拟机环境下配置centos为静态IP的步骤
一.修改centos配置文件 配置文件位于/etc/sysconfig/network-scripts/ifcfg-eth0 修改的内容为: ONBOOT=yes BOOTPROTO=static I ...
- [Python设计模式] 第10章 怎么出试卷?——模版方法模式
github地址:https://github.com/cheesezh/python_design_patterns 题目 小时候数学老师的随堂测验,都是老师在黑板上写题目,学生在下边抄,然后再做题 ...
- JPA中自动使用@Table(name = "userTab")后自动将表名、列名添加了下划线的问题
一.问题 JPA中自动使用@Table(name = "userTab")后自动将表名.列名添加了下划线的问题,如下图: 二.解决 在application.properties文 ...
- 【java】解析java网络
目录结构: contents structure [+] 模拟Post与Get请求 设置Authorization头信息 基于TCP的网络编程 TCP协议简介 半关闭的Socket TCP长链接 TC ...
- JDK自带JVM性能调优监控工具jps、jstack、jmap、jhat、jstat
原文地址:https://www.jianshu.com/p/db954cb968fb JVM性能调优监控工具jps.jstack.jmap.jhat.jstat位于JDK的bin目录,这些工具短小精 ...
- TCP中的KeepAlive与HTTP中的Keep-Alive
KeepAlive 与 Keep-Alive 前言 昨天被问到了HTTP中Keep-Alive的概念,看名字我只知道是保持连接用的,但是对于他怎么结束连接,为什么要用他这些就不是很清楚了,今天查了一下 ...
- 《软件测试自动化之道》读书笔记 之 基于反射的UI测试
<软件测试自动化之道>读书笔记 之 基于反射的UI测试 2014-09-24 测试自动化程序的任务待测程序测试程序 启动待测程序 设置窗体的属性 获取窗体的属性 设置控件的属性 ...
- css font-family常用的黑体宋体等字体中英文对照
资料来源: https://www.cnblogs.com/EnSnail/p/6792853.html 在实现网页效果时,细节很重要,字体也不例外,CSS:font-family常用字体中英文对照如 ...