Here’s a short note on Gibbs sampling, explaining a simple case with two random variables: gibbs.pdf. Source code: gibbs_2x2.py (run this file using Sage). You can browse all the related files here.

My note and source code follows the 2x2 example in this paper (click for a local copy): Casella, George; George, Edward I. (1992). “Explaining the Gibbs sampler”. The American Statistician 46 (3): 167–174.