Top-down random walk of one neutron colliding with moderator nuclei, plus the distribution of collisions needed to reach thermal energy.
The science
A neutron of mass 1 scatters elastically off a nucleus of mass number A. For isotropic scattering in the centre-of-mass frame the energy ratio after one collision is E'/E = (A^2 + 2A cos(theta) + 1) / (A+1)^2, so the neutron keeps between ((A-1)/(A+1))^2 and 100 % of its energy. The average logarithmic energy loss is energy independent: xi = 1 + (A-1)^2 / (2A) * ln((A-1)/(A+1)), with xi = 1 for hydrogen.
Therefore the mean number of collisions to slow from E0 to the thermal energy 0.025 eV is about N = ln(E0/Eth) / xi: roughly 18 for hydrogen and over 100 for carbon. This page samples that scattering law with a seeded random generator, draws one neutron's path with true lab-frame deflection angles (heavy nuclei barely deflect it), and builds the distribution of N over all histories.
Simplifications: no absorption, no up-scattering from thermal motion, constant step length, isotropic centre-of-mass scattering, no chemical binding (which matters below about 1 eV).