# Maxwell-Boltzmann distribution in Lennard Jones units

I'm studying thermostats in Molecular Dynamics. A very easy way (and poor, but I don't care for the moment) to implement a thermostat is to randomize momenta at some steps.

These new momenta are drawn from the Maxwell-Boltzmann distribution

$$\mathcal{P}(p) = \sqrt{\frac{1}{(2\pi m k_B T)^3}}e^{-\frac{p^2}{2mk_B T}}$$

while in my pseudocode I have:

p[i][j] = sqrt(m_i/beta)*gasdev()


where gasdev() generates a normal distribution of zero mean and unitary variance. This translated into a proper formula is:

$$\mathcal{P}(p) = e^{-\frac{p^2}{2m k_B T}}$$

that is quite different in the dependence on T and m.

How are the two related?

I think it is a matter of units, since I'm using LJ units, but I can not go from one to the other.

• I think you should clarify the question a bit more if you want someone who is not an expert to understand (never mind if you only need experts' answers). For example, what is "gasdev()" and "that is quite different" from what? – ophelia Feb 10 '16 at 10:47
• done, thanks for the suggestion! there was also a mistake actually :) – iacolippo Feb 10 '16 at 11:06
• Your "translation" is wrong. You draw a random number and scale it, this means you change the variance not the norm of the distribution, i.e. $P \propto \exp {( - (p/sqrt(m_i/beta))^2/2}$ (the norm is such that Int P =1) – Bort Feb 10 '16 at 11:15
• @Bort: yes, you're right. Stupid mistake. But I'm still missing a 1/2 and the prefactor – iacolippo Feb 10 '16 at 11:22
• you misread/I miswrote the equation, the 1/2 is in the exponent (the normal distribution is $\displaystyle \propto e^{-x^2/2}$). The norm/prefactor kann be understand like this: you have p=f*x with $P(x) \mathrm{d}^3x =1/\sqrt{2 \pi}^3 e^{-x^2/2} \mathrm{d}^3x = P(p) \mathrm{d}^3p$ ("Transformation rule" of probability distributions) now plugging in x in the middle part you get the desired result – Bort Feb 10 '16 at 12:53