= Solution
\b[TODO: Complete the data-specific numerical results and diagnostics when the original `Iris_data.csv` is available.]
Estimate the <posterior mean> by averaging the retained states:
$$
\boxed{\widehat{\mathbb E[\mu\mid x]}=\frac1{9000}\sum_{t=1001}^{10000}\mu_t}.
$$
The exact <truncated normal distribution> reference is
$$
\boxed{\mathbb E[\mu\mid x]=m+s\frac{\phi(m/s)}{\Phi(m/s)}},\qquad
m=\bar x-\frac1{3n},\quad s=n^{-1/2}.
$$
For a <posterior> well separated from zero, the truncation correction is tiny and the <posterior mean> is approximately $\bar x-1/(3n)$, slightly below the <sample mean>.
The R continuation prints the <Monte Carlo estimator>, its approximate batch-based <Monte Carlo standard error>, and the exact value for comparison:
``
posterior_mean_mc <- mean(post)
posterior_mean_exact <- m + s * exp(dnorm(m/s, log = TRUE) -
pnorm(m/s, log.p = TRUE))
# Nonoverlapping batches account approximately for serial dependence.
batch_length <- floor(sqrt(length(post)))
number_batches <- floor(length(post)/batch_length)
used <- post[seq_len(batch_length * number_batches)]
batch_averages <- colMeans(matrix(used, nrow = batch_length))
mcse <- sd(batch_averages)/sqrt(number_batches)
cat("Posterior mean, MCMC =", posterior_mean_mc,
" approximate MCSE =", mcse, "\n")
cat("Posterior mean, exact =", posterior_mean_exact, "\n")
``
The batch length must be long enough relative to the chain's dependence for this uncertainty estimate to be reliable. \b[No numerical data-specific <posterior mean> is determined by the supplied paper alone.]
Back to article page