Posted on Categories:Bayesian Analysis, 统计代写, 统计代考, 贝叶斯分析

# 统计代写|贝叶斯分析代考Bayesian Analysis代写|THE METROPOLIS–HASTINGS ALGORITHM

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|THE METROPOLIS–HASTINGS ALGORITHM

The Metropolis-Hastings algorithm (MH) is an MCMC sampling algorithm that uses a proposal distribution to draw samples from the target distribution. Let $\Omega$ be the sample space of the target distribution $p(U \mid \boldsymbol{X})$ (for this example, $U$ can represent the latent variables in the model). The proposal distribution is then a function $q\left(U^{\prime} \mid U\right) \in \Omega \times \Omega \rightarrow[0,1]$ such that each $u \in \Omega$ defines a distribution $q\left(U^{\prime} \mid u\right)$. It is also assumed that sampling from $q\left(U^{\prime} \mid u\right)$ for any $u \in \Omega$ is computationally efficient. The target distribution is assumed to be computable up to its normalization constant.

The Metropolis-Hastings sampler is given in Algorithm 5.5. It begins by initializing the state of interest with a random value, and then repeatedly samples from the underlying proposal distribution. Since the proposal distribution can be quite different from the target distribution, $p(U \mid \boldsymbol{X})$, there is a correction step following Equation 5.16 that determines whether or not to accept the sample from the proposal distribution.

Just like the Gibbs sampler, the MH algorithm streams samples. Once the chain has converged, one can continuously produce samples (which are not necessarily independent) by re-peating the loop statements in the algorithm. At each step, $u$ can be considered to be a sample from the underlying distribution.

We mentioned earlier that the distribution $p$ needs to be computable up to its normalization constant. This is true even though Equation 5.16 makes explicit use of the values of $p$; the acceptance ratio always computes ratios between different values of $p$, and therefore the normalization constant is cancelled.

Accepting the proposed samples using the acceptance ratio pushes the sampler to explore parts of the space that tend to have a higher probability according to the target distribution. The acceptance ratio is proportional to the ratio between the probability of the next state and the probability of the current state. The larger the next state probability is, the larger the acceptance ratio is, and therefore it is more likely to be accepted by the sampler. However, there is an important correction ratio that is multiplied in: the ratio between the value of the proposed distribution in the current state and the value of the proposed distribution in the next state. This correction ratio controls for the bias that the proposal distribution introduces by having higher probability mass in certain parts of the state space over others (different than those of the target distribution).

It is important to note that the support of the proposal distribution should subsume (or be equal to) the support of the target distribution. This ensures that the underlying Markov chain is recurrent, and that all sample space will be explored if the sampler is run long enough. The additional property of detailed balance (see Section 5.3.2) is also important to ensure that the correctness of a given MCMC sampler is satisfied through the correction step using the acceptance ratio.

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|VARIANTS OF METROPOLIS–HASTINGS

Metropolis et al. (1953) originally developed the Metropolis algorithm, where the proposal distribution is assumed to be symmetric (i.e., $\left.q\left(U^{\prime} \mid U\right)=q\left(U \mid U^{\prime}\right)\right)$. In this case, the acceptance ratio in Equation 5.16 consists only of the ratio between the distribution of interest at the next potential state and the current state. Hastings (1970) later generalized it to the case of an asymmetric $q$, which yielded the Metropolis-Hastings algorithm.

Another specific case of the Metropolis-Hastings algorithm is the one in which $q\left(U^{\prime} \mid U\right)=q\left(U^{\prime}\right)$, i.e., the proposal distribution does not depend on the previous state. In this case, the $\mathrm{MH}$ algorithm reduces to an independence sampler.

An important variant of the Metropolis-Hastings given in Algorithm 5.5 is the component-wise $\mathrm{MH}$ algorithm. The component-wise $\mathrm{MH}$ algorithm is analogous to the $\mathrm{Gibbs}$ sampler, in that it assumes a partition over the variables in the target distribution, and it repeatedly changes the state of each of these variables using a collection of proposal distributions.
With the component-wise $\mathrm{MH}$ algorithm, one defines a set of proposal distributions $q_i\left(U^{\prime} \mid U\right)$, where $q_i$ is such that it allocates a non-zero probability mass only to transitions in the state space that keep $U_{-i}$ intact, perhaps changing $U_i$. More formally, $q_i\left(U_{-i}^{\prime} \mid U\right)>0$ only if $U_{-i}^{\prime}=U_{-i}$. Then, the component-wise $\mathrm{MH}$ algorithm alternates randomly or systematically, each time sampling from $q_i$ and using the acceptance ratio:
$$\alpha_i=\min \left{1, \frac{p\left(u^{\prime} \mid \boldsymbol{X}\right) q_i\left(u \mid u^{\prime}\right)}{p(u \mid \boldsymbol{X}) q_i\left(u^{\prime} \mid u\right)}\right},$$
to reject or accept the new sample. Each acceptance changes only a single coordinate in $U$.
The Gibbs algorithm can be viewed as a special case of the component-wise $\mathrm{MH}$ algorithm, in which
$$q_i\left(u^{\prime} \mid u\right)= \begin{cases}p\left(u_i^{\prime} \mid u_{-i}, \boldsymbol{X}\right), & \text { if } u_{-i}^{\prime}=u_{-i} \ 0 & \text { otherwise }\end{cases}$$

# 贝叶斯分析代写

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|THE METROPOLIS-HASTINGS ALGORITHM

Metropolis-Hastings 算法 (MH) 是一种 MCMC 采样算法，它使用建议分布从目标分布中抽取样本。让 $\Omega$ 是 目标分布的样本空间 $p(U \mid \boldsymbol{X})$ (对于这个例子， $U$ 可以表示模型中的潜在变量)。建议分布是一个函数 $q\left(U^{\prime} \mid U\right) \in \Omega \times \Omega \rightarrow[0,1]$ 这样每个 $u \in \Omega$ 定义分布 $q\left(U^{\prime} \mid u\right)$. 还假设从 $q\left(U^{\prime} \mid u\right)$ 对于任何 $u \in \Omega$ 计 算效率高。假设目标分布在其归一化常数之前是可计算的。

Metropolis-Hastings 采样器在算法 5.5 中给出。它首先使用随机值初始化感兴趣的状态，然后从基础建议分 布中重复采样。由于建议分布可能与目标分布有很大不同， $p(U \mid \boldsymbol{X})$ ，在公式 5.16 之后有一个校正步骤，用 于确定是否接受建议分布中的样本。

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|VARIANTS OF METROPOLIS-HASTINGS

Metropolis-Hastings 算法的另一个具体情况是 $q\left(U^{\prime} \mid U\right)=q\left(U^{\prime}\right)$ ，即提案分布不依赖于先前的状态。在 这种情况下，MH算法简化为独立采样器。

\left 缺少或无法识别的分隔符

Gibbs 算法可以看作是 component-wise 的一个特例 $M H$ 算法，其中
$q_i\left(u^{\prime} \mid u\right)=\left{p\left(u_i^{\prime} \mid u_{-i}, \boldsymbol{X}\right), \quad\right.$ if $u_{-i}^{\prime}=u_{-i} 0 \quad$ otherwise

avatest.org 为您提供可靠及专业的论文代写服务以便帮助您完成您学术上的需求，让您重新掌握您的人生。我们将尽力给您提供完美的论文，并且保证质量以及准时交稿。除了承诺的奉献精神，我们的专业写手、研究人员和校对员都经过非常严格的招聘流程。所有写手都必须证明自己的分析和沟通能力以及英文水平，并通过由我们的资深研究人员和校对员组织的面试。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。