Gibbs sampling, rejection and ancestral sampling