Solution (source code)

= Solution

A <credibility estimate> blends the risk's own <sample mean> with a population or prior <expected value>. In the basic equal-exposure form it is $Z\overline X+(1-Z)\mu$, where the <credibility factor> $Z\in[0,1]$ is the weight attached to the individual experience. More data ordinarily increase that weight; greater within-risk variation relative to between-risk variation reduces it.

Write $m(\theta)=\mu(\theta)$ for the conditional claim <expected value>, keeping $\mu$ for the prior-level parameter. Normalization of the <probability density function> gives
$$
q(\theta)=\int_0^\infty p(x)e^{-\theta x}\,dx.
$$
At interior points of its finite domain, <differentiation under the integral sign> yields
$$
q'(\theta)=-\int_0^\infty xp(x)e^{-\theta x}\,dx,
\qquad
\boxed{m(\theta)=-\frac{q'(\theta)}{q(\theta)}.}
$$
This is an instance of the <exponential-family derivative identities> for natural parameter $-\theta$. The minus sign is present in the PDF and is lost in the converted TeX. The <conditional variance> is likewise $(\log q)''(\theta)$.

Differentiate the log of the <natural conjugate prior>:
$$
\frac{\pi'(\theta)}{\pi(\theta)}
=-k\frac{q'(\theta)}{q(\theta)}-k\mu
=k\bigl(m(\theta)-\mu\bigr).
$$
Integrate on a compact subinterval and then let its endpoints approach those of the parameter interval. The prescribed vanishing of the prior density eliminates the boundary term. Since $m(\theta)\geq0$, <monotone convergence theorem> justifies the limit of its expectation, and the identity gives
$$
\boxed{\mathbb E_\pi[m(\Theta)]=\mu.}
$$
In particular the assumed proper prior and boundary conditions themselves establish this first-moment integrability.

For $T=\sum_{i=1}^nx_i$ and $\overline x=T/n$, <conditional independence> makes the <likelihood function> proportional to $q(\theta)^{-n}e^{-\theta T}$. Multiplication by the <prior distribution> gives the <Bayesian posterior>
$$
\pi(\theta\mid\mathbf x)\propto q(\theta)^{-(k+n)}e^{-\theta(k\mu+T)}.
$$
Thus this is a <conjugate prior> family, with updated parameters
$$
\boxed{k_n=k+n,\qquad \mu_n=\frac{k\mu+T}{k+n}.}
$$

The integration-by-parts calculation for the <posterior mean> also needs vanishing posterior boundary values. Here that property can be checked, rather than assumed. Let $a,b$ be the essential lower and upper endpoints of the claim support. Every nondegenerate tilted claim law has $a<m(\theta)<b$, so the established prior mean satisfies $a<\mu<b$. Supported observations have $\overline x\in[a,b]$; hence $a<\mu_n<b$. At a finite parameter endpoint the prior's vanishing forces $q(\theta)\to\infty$, because its exponential factor has a finite positive limit; the increased power $q^{-k_n}$ makes the posterior vanish there too. At $\theta\to+\infty$, choose $a<d<\mu_n$ with positive base-measure mass below $d$. Then $q(\theta)\geq C e^{-d\theta}$ and the unnormalized posterior is at most $C^{-k_n}e^{-k_n(\mu_n-d)\theta}\to0$. At $\theta\to-\infty$, choose $\mu_n<d<b$ with positive mass above $d$ to obtain the corresponding bound $C^{-k_n}e^{k_n(d-\mu_n)\theta}\to0$. These bounds also ensure posterior propriety at infinite endpoints. This is the <endpoint control for a Laplace-family conjugate posterior>.

Apply the previous score integration to the <Bayesian posterior>. The <natural conjugate credibility identity> is
$$
\boxed{\mathbb E[m(\Theta)\mid\mathbf x]=\mu_n
=\frac n{n+k}\overline x+\frac k{n+k}\mu.}
$$
Thus \b[$Z=n/(n+k)$] is the <credibility factor>. This is an exact <posterior mean>, rather than an affine approximation to one.

For the specific shape-two <gamma distribution>, take
$$
\boxed{p(x)=x,\qquad q(\theta)=\theta^{-2},\qquad \theta>0.}
$$
Then $m(\theta)=2/\theta$ and $\operatorname{Var}(X\mid\theta)=2/\theta^2$. The <gamma rate gamma conjugacy> prior is
$$
\boxed{\pi(\theta)=\frac{(k\mu)^{2k+1}}{\Gamma(2k+1)}\theta^{2k}e^{-k\mu\theta},\qquad \theta>0,}
$$
that is, $\Theta\sim\operatorname{Gamma}(2k+1,\text{rate }k\mu)$. Its normalizing constant in the notation of the question is $c(\mu,k)=\Gamma(2k+1)/(k\mu)^{2k+1}$. The <gamma distribution> density vanishes at both zero and infinity for $k>0$. The posterior has shape $2k+2n+1$ and rate $k\mu+T$, so its conditional-mean <posterior mean> is again $(k\mu+T)/(k+n)$.

For the last calculation, <gamma distribution> integration gives
$$
\mathbb E[\Theta^{-1}]=\frac{k\mu}{2k}=\frac\mu2,
\qquad
\mathbb E[\Theta^{-2}]=\frac{(k\mu)^2}{2k(2k-1)}.
$$
The second identity requires the printed $k>1/2$. Therefore the <expected process variance> and <variance of hypothetical means>, denoted by $a,b$ in this question, are
$$
\boxed{a=\mathbb E[2/\Theta^2]=\frac{k\mu^2}{2k-1},\qquad
b=\operatorname{Var}(2/\Theta)=\frac{\mu^2}{2k-1}.}
$$
Consequently $a/b=k$, and the <Bühlmann credibility factor> agrees with the exact Bayesian weight:
$$
\boxed{Z=\frac n{n+k}=\frac n{n+a/b}.}
$$
This is the <exact Bühlmann credibility for gamma claims>, expressed using the reciprocal rate as the random scale. The symbols $a,b$ here are the process and between-risk <variances>, respectively; their roles should not be interchanged when comparing with other notation for the <Bühlmann model>.