This is related to this question. I am concerned about the expected value of a function estimated using sampling.

If the samples were obtained by a sampling method such as Gibbs sampling, and if I do the following estimation,

$\mathbb{E}[g(x)] \approx \hat{g} = \dfrac{1}{N}\sum g(x_s) \quad s=1\dots N$

Can we say $\mathbb{E}[\hat{g}] = \mathbb{E}[g(x)]$ ?

I think we can arrive at this by

$\mathbb{E} \big[\dfrac{1}{N}\sum g(x_s)\big] = \dfrac{1}{N}\sum \mathbb{E}[g(x)] = \mathbb{E}[g(x)]$.

  • 3
    $\begingroup$ if the g(x_s) are each i.i.d samples then they each have the same expected value, and any given combination has the same expected value. Perhaps I'm misunderstanding the question. $\endgroup$
    – redcalx
    Commented Aug 14, 2016 at 6:54

1 Answer 1


If the Gibbs sampler has not converged as yet, then $x_s$ is not a draw from the equilibrium distribution. Thus the expectation is not calculated with respect to the equilibrium distribution. Let $P^s$ be the distribution of the $x_s$ draw of the Gibbs sampler. If the sampler has not converged then $P^s \ne \pi$ where $\pi$ is the equilibrium distribution. So there will be some left over bias.

If the sampler has converged, then $P^s$ is sufficiently close to $\pi$ so that, $$E_{\pi}\left[ \dfrac{1}{N} \sum_{s=1}^{N} g(x_s) \right] = \dfrac{1}{N} E[g(x_s)] = E[g(x)].$$

As a side, the more important question is that in practical settings it doesn't matter as much whether the sampler has converged perfectly, since as you get more samples, you do better estimation. Here is the reason.

If instead of Gibbs sampling, the samples were obtained as iid samples, then the sample mean is a good estimate of the truth since $$\hat{g} = \dfrac{1}{N} \sum_{s= 1}^{N} g(x_s) \overset{a.s.}{\to} E[g(x)] \quad \text {as } N \to \infty, $$

where $\overset{a.s.}{\to}$ means convergence almost surely. This is often called the Strong Law of Large Numbers (SLNN). It is due to this convergence, if $N$ is large enough, we know that $E[g(x)] \approx \hat{g}$.

This SLLN also holds for MCMC sampling (and hence for Gibbs sampling) if the Markov chain is Harris ergodic, i.e., the Markov chain is irreducible, aperiodic and positive Harris recurrent. This seems difficult to verify, but in fact holds for most MCMC algorithms.

If your full conditionals in the Gibbs sampler are all valid distributions, then the Gibbs sampler is Harris ergodic, and thus the strong law of large numbers hold.

  • $\begingroup$ Thank you for the detailed answer. Is there any reference that contains proofs for Harris ergodic Markov chain gives iid samples ? and also Harris ergodicity in general ? $\endgroup$ Commented Aug 15, 2016 at 5:39
  • 1
    $\begingroup$ One fundamental issue is that it is almost always impossible to assert that "the sampler has converged". Except for perfect sampling (rarely applicable) and renewal (usually costly), I know of no technique that allows to spot exactly the time $s$ when $X_s$ starts being distributed from the target. $\endgroup$
    – Xi'an
    Commented Jan 27, 2019 at 10:26
  • 1
    $\begingroup$ @Xi'an Certainly. The only other way I can think of is if you can possibly start from stationarity. Like a rejection sampler that's inefficient for Monte Carlo, but reasonable for one starting value. $\endgroup$ Commented Jan 27, 2019 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.