Here are the python programs related to Week 7:

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 7:

4.2.1 (density matrix for bosons), 4.2.2 (permutation cycles counting, recursion formula for the partition function), 4.2.4 (condensate fraction, probability of cycle lengths), 4.2.5 (direct sampling algorithm for ideal bosons in a trap)