# Find posterior distribution for uniform distribution

Given X with uniform distribution in the interval [μ,μ+θ].

1. Suppose θ is given. Find the posterior distribution with prior distribution on your own.
2. From that, find the Bayesian estimator with quadratic loss function.
3. If θ is not given, how to find μ.

Actually, this is a tough question in my last exam and I don't know how to approach it. I have read some papers and I solved it based on what I got.

My solution:

And I don’t know how to proceed. Is it correct with this approach? Please give me some explanations. Thank you very much.

1. The posterior density is indeed proportional to $\mathbb{I}_{xn-\theta\le\mu\le x1}$, hence a Uniform $U(xn-\theta,x1)$. Your prior $\pi(\mu)=1$ is not Uniform but flat, as it is improper;
2. The Bayes estimator for the quadratic loss is indeed the posterior mean, which for a Uniform $U(xn-\theta,x1)$ equals$$\frac{xn+x1-\theta}{2}$$
3. If $\theta$ is unknown, you first need to set a prior on $\theta$. For instance, I would take the scale improper prior $\pi(\theta)\propto 1/\theta$. You then need to find the marginal posterior of $\mu$ given $x$ by integrating out $\theta$:$$\pi(\mu|\mathbf{x})=\int_0^\infty p(\theta,\mu|\mathbf{x})\,\text{d}\theta$$The joint posterior $p(\theta,\mu|\mathbf{x})$ can be derived from$$p(\theta,\mu|\mathbf{x})\propto\pi(\theta)\pi(\mu)f(\mathbf{x}|\mu,\theta)=\frac{1}{\theta}\frac{1}{\theta^n}\mathbf{I}_{xn-\theta\le\mu\le x1}$$