资源简介
MCMC算法,metropolis hasting算法的实现代码,可正常运行,加入了自己的注释,对于正在学习MCMC采样的同学会提供一定的帮助。
代码片段和文件信息
function [samples naccept] = MH(target proposal xinit Nsamples targetArgs proposalArgs proposalProb)
% Metropolis-Hastings algorithm
% Inputs
% target returns the unnormalized log posterior called as ’p = exp(target(x targetArgs{:}))’
% proposal is a fn as ’xprime = proposal(x proposalArgs{:})’ where x is a 1xd vector
% xinit is a 1xd vector specifying the initial state
% Nsamples - total number of samples to draw
% targetArgs - cell array passed to target
% proposalArgs - cell array passed to proposal
% proposalProb - optional fn called as ’p = proposalProb(xxprime proposalArgs{:})’
% computes q(xprime|x). Not needed for symmetric proposals (Metropolis algorithm)
%
% Outputs
% samples(s:) is the s’th sample (of size d)
% naccept = number of accepted move
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2289 2014-10-26 13:50 MCMC_Metropolis_hasting_1D\MH.m
文件 2037 2014-10-26 14:03 MCMC_Metropolis_hasting_1D\mhDemoMOG.m
文件 560 2014-10-26 13:14 MCMC_Metropolis_hasting_1D\mogProb.m
文件 92 2014-10-26 13:19 MCMC_Metropolis_hasting_1D\proposal.m
文件 159 2014-10-26 13:19 MCMC_Metropolis_hasting_1D\proposalProb.m
文件 127 2014-10-26 13:14 MCMC_Metropolis_hasting_1D\target.m
目录 0 2015-06-19 14:21 MCMC_Metropolis_hasting_1D
----------- --------- ---------- ----- ----
5264 7
评论
共有 条评论