# Bayesian minimum mean square error estimator

In Fundamentals of Statistical Signal Processing, Estimation Theory, by Steven M. Kay the author shows on p. 312-313 that the estimator $p(A\mid x)$ minimises the Bayesian mean square error when you want to use the data $\boldsymbol{x}$ to estimate the parameter $A$. In the beginning of the proof he writes

$\text{Bmse}(\hat{A})=\int[\int(A-\hat{A})p(A\mid \boldsymbol{x})dA ]p(x)d\boldsymbol{x}$

and says that if we can minimise the expression in brackets for each $\boldsymbol{x}$ then the Bmse will be minimised. He then fixes $\boldsymbol{x}$ and says that $\hat{A}$ is a scalar variable. He also takes the partial derivative of $\int (A-\hat{A})^2p(A\mid \boldsymbol{x})dA$ with respect to $\hat{A}=\hat{A}(\boldsymbol{x})$.

My questions are:

1. Exactly what does it mean that $\hat{A}=\hat{A}(\boldsymbol{x})$ is a scalar variable when we fix $\boldsymbol{x}$?
2. Why is it possible to view $\int (A-\hat{A})^2p(A\mid \boldsymbol{x})dA$ as a function of $\hat{A}$, when previously $\int (A-\hat{A})^2p(A\mid \boldsymbol{x})dA$ was considered a function of $\boldsymbol{x}$?

My attempt of a solution: Normally $\hat{A}(\boldsymbol{x})$ assigns a unique real value to each possible realisation $\boldsymbol{x}$ (i.e $\hat{A}(\boldsymbol{x})\in \mathrm{R}$). Now, however, we fix $\boldsymbol{x}$ which means it take a specific value, say $\boldsymbol{x}_0$, and let $\hat{A}$ be free to vary. This means $\int(A-\hat{A})^2p(A\mid \boldsymbol{x}_0)dA=f(\hat{A})$. Thus we can vary the value $\hat{A}=\hat{A}(\boldsymbol{x})$ assigns to $\boldsymbol{x}_0$. We ask: how should $\hat{A}$ be chosen to minimise $f(\hat{A})$? The answer: we should solve $\frac{\text{d}f}{\text{d}\hat{A}}=0$. If we solve $\frac{\text{d}f}{\text{d}\hat{A}}=0$ for $\hat{A}$, the result must depend only on $\boldsymbol{x}_0$ since we integrate $A$ "away".

Edit: if you like, you can set $\hat{A}=\hat{A}(\boldsymbol{x}_0)=t$, where you can think that $\hat{A}$ is for instance $x_0^2+x_0^4=t$ ( of course you do not know the expression for $\hat{A}$ beforehand, but you do know it will be some real number). You should then consider $\frac{\text{d}f}{\text{d}t}=0$