### 统计代写|贝叶斯统计代写Bayesian statistics代考|Bayesian inference methods

statistics-lab™ 为您的留学生涯保驾护航 在代写贝叶斯统计方面已经树立了自己的口碑, 保证靠谱, 高质且原创的统计Statistics代写服务。我们的专家在代写贝叶斯统计代写方面经验极为丰富，各种代写贝叶斯统计相关的作业也就用不着说。

• Statistical Inference 统计推断
• Statistical Computing 统计计算
• Advanced Probability Theory 高等概率论
• Advanced Mathematical Statistics 高等数理统计学
• (Generalized) Linear Models 广义线性模型
• Statistical Machine Learning 统计机器学习
• Longitudinal Data Analysis 纵向数据分析
• Foundations of Data Science 数据科学基础

## 统计代写|贝叶斯统计代写beyesian statistics代考|The Bayes theorem for probability

The Bayes theorem allows us to calculate probabilities of events when additional information for some other events is available. For example, a person may have a certain disease whether or not they show any symptoms of it. Suppose a randomly selected person is found to have the symptom. Given this additional information, what is the probability that they have the disease? Note that having the symptom does not fully guarantee that the person has the disease.

To formally state the Bayes theorem, let $B_{1}, B_{2}, \ldots, B_{k}$ be a set of mutually exclusive and exhaustive events and let $A$ be another event with positive probability (see illustration in Figure 4.1). The Bayes theorem states that for any $i, i=1, \ldots, k$,
$$P\left(B_{i} \mid A\right)=\frac{P\left(B_{i} \cap A\right)}{P(A)}=\frac{P\left(A \mid B_{i}\right) P\left(B_{i}\right)}{\sum_{j=1}^{k} P\left(A \mid B_{j}\right) P\left(B_{j}\right)}$$
Example 4.1. We can understand the theorem using a simple example. Consider a rare disease that is thought to occur in $0.1 \%$ of the population. Using a particular blood test a physician observes that out of the patients with disease $99 \%$ possess a particular symptom. Also assume that $1 \%$ of the population without the disease have the same symptom. A randomly chosen person from the population is blood tested and is shown to have the symptom. What is the conditional probability that the person has the disease?

Here $k=2$ and let $B_{1}$ be the event that a randomly chosen person has the disease and $B_{2}$ is the complement of $B_{1}$. Let $A$ be the event that a randomly chosen person has the symptom. The problem is to determine $P\left(B_{1} \mid A\right)$.
We have $P\left(B_{1}\right)=0.001$ since $0.1 \%$ of the population has the disease, and $P\left(B_{2}\right)=0.999$. Also, $P\left(A \mid B_{1}\right)=0.99$ and $P\left(A \mid B_{2}\right)=0.01$. Now
\begin{aligned} P(\text { disease } \mid \text { symptom })=P\left(B_{1} \mid A\right) &=\frac{P\left(A \mid B_{1}\right) P\left(B_{1}\right)}{P\left(A \mid B_{1}\right) P\left(B_{1}\right)+P\left(A \mid B_{2}\right) P\left(B_{2}\right)} \ &=\frac{0.99 \times 0.001}{0.99 \times 0.001+0.999 \times 0.01} \ &=\frac{99}{99+999}=0.09 . \end{aligned}
The probability of disease given symptom here is very low, only $9 \%$, since the

disease is a very rare disease and there will be a large percentage of individuals in the population who have the symptom but not the disease, highlighted by the figure 999 as the second last term in the denominator above.

It is interesting to see what happens if the same person is found to have the same symptom in another independent blood test. In this case, the prior probability of $0.1 \%$ would get revised to $0.09$ and the revised posterior probability is given by:
$$P(\text { disease } \mid \text { twice positive })=\frac{0.99 \times 0.09}{0.99 \times 0.09+0.91 \times 0.01}=0.908 .$$
As expected, this probability is much higher since it combines the evidence from two independent tests. This illustrates an aspect of the Bayesian world view: the prior probability gets continually updated in the light of new evidence.

## 统计代写|贝叶斯统计代写beyesian statistics代考|Bayes theorem for random variables

The Bayes theorem stated above is generalized for two random variables instead of two events $A$ and $B_{i}$ ‘s as noted above. In the generalization, $B_{i}$ ‘s will be replaced by the generic parameter $\theta$ which we want to estimate and $A$ will be replaced by the observation random variable denoted by $Y$. Also, the probabilities of events will be replaced by the probability (mass or density) function of the argument random variable. Thus, $P\left(A \mid B_{i}\right)$ will be substituted by $f(y \mid \theta)$ where $f(\cdot$ ) denotes the probability (mass or density) function of the random variable $X$ given a particular value of $\theta$. The replacement for $P\left(B_{i}\right)$ is $\pi(\theta)$, which is the prior distribution of the unknown parameter $\theta$. If $\theta$ is

a discrete parameter taking only finite many, $k$ say, values, then the summation in the denominator of the above Bayes theorem will stay as it is since $\sum_{j=1}^{k} \pi\left(\theta_{j}\right)$ must be equal to 1 as the total probability. If, however, $\theta$ is a continuous parameter then the summation in the denominator of the Bayes theorem must be replaced by an integral over the range of $\theta$, which is generally taken as the whole of the real line.

The Bayes theorem for random variables is now stated as follows. Suppose that two random variables $Y$ and $\theta$ are given with probability density functions (pdfs) $f(y \mid \theta)$ and $\pi(\theta)$, then
$$\pi(\theta \mid y)=\frac{f(y \mid \theta) \pi(\theta)}{\int_{-\infty}^{\infty} f(y \mid \theta) \pi(\theta) d \theta},-\infty<\theta<\infty .$$
The probability distribution given by $\pi(\theta)$ captures the prior beliefs about the unknown parameter $\theta$ and is the prior distribution in the Bayes theorem. The posterior distribution of $\theta$ is given by $\pi(\theta \mid y)$ after observing the value $y$ of the random variable $Y$. We illustrate the theorem with the following example.
Example 4.2. Binomial Suppose $Y \sim \operatorname{binomial}(n, \theta)$ where $n$ is known and we assume $\operatorname{Beta}(\alpha, \beta)$ prior distribution for $\theta$. Here the likelihood function is
$$f(y \mid \theta)=\left(\begin{array}{l} n \ y \end{array}\right) \theta^{y}(1-\theta)^{n-y}$$
for $0<\theta<1$. The function $f(y \mid \theta)$ is to be viewed as a function of $\theta$ for a given value of $y$, although its argument is written as $y \mid \theta$ instead of $\theta \mid y$. This is because we use the probability density function of $Y$, which is more widely known, and we avoid introducing further notation for the likelihood function e.g. $L(\theta ; y)$.

Suppose that the prior distribution is the beta distribution (A.22) having density
$$\pi(\theta)=\frac{1}{B(\alpha, \beta)} \theta^{\alpha-1}(1-\theta)^{\beta-1}, \quad 0<\theta<1 .$$

## 统计代写|贝叶斯统计代写beyesian statistics代考|Sequential updating of the posterior distribution

Consider the denominator in the posterior distribution. The denominator, given by, $\int_{-\infty}^{\infty} f(y \mid \theta) \pi(\theta) d \theta$ or $\int_{-\infty}^{\infty} f\left(y_{1}, \ldots, y_{n} \mid \theta\right) \pi(\theta) d \theta$ is free of the unknown parameter $\theta$ since $\theta$ is only a dummy in the integral, and it has been integrated out in the expression. The posterior distribution $\pi\left(\theta \mid y_{1}, \ldots, y_{n}\right)$ is to be viewed as a function of $\theta$ and the denominator is merely a constant. That is why, we often ignore the constant denominator and write the posterior distribution $\pi\left(\theta \mid y_{1}, \ldots, y_{n}\right)$ as
$$\pi\left(\theta \mid y_{1}, \ldots, y_{n}\right) \propto f\left(y_{1}, \ldots, y_{n} \mid \theta\right) \times \pi(\theta)$$
By noting that $f\left(y_{1}, \ldots, y_{n} \mid \theta\right)$ provides the likelihood function of $\theta$ and $\pi(\theta)$ is the prior distribution for $\theta$, we write:
Posterior $\propto$ Likelihood $\times$ Prior.
Hence we always know the posterior distribution up-to a normalizing constant. Often we are able to identify the posterior distribution of $\theta$ just by looking at the numerator as in the two preceding examples.

The structure of the Bayes theorem allows sequential updating of the posterior distribution. By Bayes theorem we “update” the prior belief $\pi(\theta)$ to $\pi(\theta \mid \mathbf{y})$. Note that $\pi\left(\theta \mid y_{1}\right) \propto f\left(y_{1} \mid \theta\right) \pi(\theta)$ and if $Y_{2}$ is independent of $Y_{2}$ given the parameter $\theta$, then:
\begin{aligned} \pi\left(\theta \mid y_{1}, y_{2}\right) & \propto & f\left(y_{2} \mid \theta\right) f\left(y_{1} \mid \theta\right) \pi(\theta) \ & \propto f\left(y_{2} \mid \theta\right) \pi\left(\theta \mid y_{1}\right) \end{aligned}
Thus, at the second stage of data collection, the first stage posterior distribution, $\pi\left(\theta \mid y_{1}\right)$ acts as the prior distribution to update our belief about $\theta$ after. Thus, the Bayes theorem shows how the knowledge about the state of nature represented by $\theta$ is continually modified as new data becomes available. There is another strong point that jumps out of this sequential updating. It is possible to start with a very weak prior distribution $\pi(\theta)$ and upon observing data sequentially the prior distribution gets revised to a stronger one, e.g. $\pi\left(\theta \mid y_{1}\right)$ when just one observation has been recorded – of course, assuming that data are informative about the unknown parameter $\theta$.

## 统计代写|贝叶斯统计代写beyesian statistics代考|Bayes theorem for random variables

F(是∣θ)=(n 是)θ是(1−θ)n−是

## 有限元方法代写

tatistics-lab作为专业的留学生服务机构，多年来已为美国、英国、加拿大、澳洲等留学热门地的学生提供专业的学术服务，包括但不限于Essay代写，Assignment代写，Dissertation代写，Report代写，小组作业代写，Proposal代写，Paper代写，Presentation代写，计算机作业代写，论文修改和润色，网课代做，exam代考等等。写作范围涵盖高中，本科，研究生等海外留学全阶段，辐射金融，经济学，会计学，审计学，管理学等全球99%专业科目。写作团队既有专业英语母语作者，也有海外名校硕博留学生，每位写作老师都拥有过硬的语言能力，专业的学科背景和学术写作经验。我们承诺100%原创，100%专业，100%准时，100%满意。

## MATLAB代写

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