1
$\begingroup$

Given a sample $(1,2,5,2.5,3,7)$, and known $\sigma^2 = 4$ with possible values for prior mean of $(0,0.5,1,1.5)$ all equally likely, find the posterior distribution and the posterior probability that $\mu\leq 1$

So in R I have:

> sample = c(1,2,5,2.5,3,7)
> m = c(0,0.5,1,1.5)
> prior = (rep(1/4,4))
> lilklihood = dnorm(mean(sample), mean = m, sd = 2/sqrt(length(sample)))
> posterior = prior*liklihood/sum(prior*liklihood)
> posterior
[1] 0.002021756 0.021735920 0.160607934 0.815634390

So my posterior distribution just is this vector correct? The thing I find is that all my values are actually less than 1, so is posterior probability that $\mu\leq 1$ just 1?

$\endgroup$
7
  • $\begingroup$ It is not clear what you mean. You mention Dirichlet distribution in the title, but use Gaussians in the code, those two are completely unrelated. It is not clear what are you trying to do. $\endgroup$
    – Tim
    Mar 14, 2022 at 13:08
  • $\begingroup$ @Tim, I think you have misread "Discrete" as "Dirichlet". $\endgroup$
    – Peter Pang
    Mar 14, 2022 at 14:30
  • $\begingroup$ @PeterPang please do not make edits that change the meanings of questions or answers by others. Edits are meant for things like typos, fixing broken links, formatting, etc, not for re-wording the content. $\endgroup$
    – Tim
    Mar 14, 2022 at 14:33
  • $\begingroup$ @Tim, I thought the question was closed because it was not detailed enough and therefore asking for people to edit and add details. $\endgroup$
    – Peter Pang
    Mar 14, 2022 at 14:36
  • $\begingroup$ @PeterPang it was asking OP to edit. Please see meta.stackexchange.com/help/privileges/edit $\endgroup$
    – Tim
    Mar 14, 2022 at 14:39

1 Answer 1

4
$\begingroup$

The resulting posterior is the posterior probability associated with four possible values for the mean; therefore; $$ \begin{aligned} &P(\mu = 0 \vert \textrm{data}) &&= 0.002021756,\\ &P(\mu = 0.5 \vert \textrm{data}) &&= 0.021735920,\\ &P(\mu = 1 \vert \textrm{data}) &&= 0.160607934,\\ &P(\mu = 1.5 \vert \textrm{data}) &&= 0.815634390,\\ \end{aligned} $$ therefore $P(\mu \leq 1 \vert \textrm{data})$ is given by $$ \begin{aligned} P(\mu \leq 1 \vert \textrm{data}) &= P(\mu = 0 \vert \textrm{data}) + P(\mu = 0.5 \vert \textrm{data}) + P(\mu = 1 \vert \textrm{data})\\ &= 0.18436561\\ &\approx 18\%. \end{aligned} $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.