Suppose we have iid observation with the following model $ Y_t \sim \mathcal{N}(\mu,1/\mu) , t=1,2,..T$
The question is " Assuming a flat prior on $(0 ,\infty )$ find a 95% HPD interval for $\mu"$
The aditional information that the problem gives is: $T=6; \sum{y_i}^{2}=76;\sum{y_i}=18$
this is my first try, $p(\mu)=\mu^{-1}1_{y>0}$ then
$ \begin{eqnarray*} p(\mu\vert Y) & \propto & p(Y \vert \mu) p(\mu) & \propto \mu^{T}\exp[\sum{(-\mu/2){}(y_i-\mu)}^{2} ] \mu^{-1}1_{y>0} \end{eqnarray*} $
$Pr(\mu ϵ C│y)=\int_{a}^{b}p(\mu\vert Y)d\mu=\int_{a}^{b} \mu^{T-1}\exp[\sum{(-\mu/2){}(y_i-\mu)}^{2} ] 1_{y>0}d\mu=0.95$
I think this problem doesn´t have an analytical solution, so the solution is numeric. The question is which algorithm ,step by step, can I use to solve it .
Update
$\sum{(y_i-\mu)}^{2}= \sum{y_i}^{2}-2\mu\sum{y_i}+T\mu^{2}=76-36\mu+6\mu^{2}$ $\ (-\mu/2) \sum{(y_i-\mu)}^{2}= -38\mu+18\mu^{2}-3\mu^{3}$
$Pr(\mu ϵ C│y)=\int_{a}^{b}p(\mu\vert Y)d\mu=\int_{a}^{b} \mu^{5}\exp[-38\mu+18\mu^{2}-3\mu^{3} ] 1_{y>0}d\mu=0.95$
%%Matlab Code
a=0.0001;b=0.0001;step=0.0001;
x=[a:step:1];
fx= x.^(5).*exp(-38.*x+18.*(x.^2)-3.*(x.^3)); plot(x,fx)
How can I find (a,b) that give me a 0.95 credible region with the minimum distiance between a and b