Here are the python programs related to Week 4:

And here are some sections of the SMAC book (Krauth W., "Statistical mechanics: algorithms and computations". OUP Oxford, 2006) related to the topics treated in Week 4:

1.2.1 (random number generator), 1.2.3 (discrete distributions, tower sampling), 1.2.4 (connection between sampling and integration), 1.2.5 (sampling a Gaussian), 1.2.6 (sampling a sphere or its surface), 2.2.4 (Maxwell distribution of velocities)