Maxwell Distribution

The Maxwell distribution or Maxwell-Boltzmann distribution is the distribution of the speed of molecules in equilibrium. The Probability Density Function (PDF) is:

$$f(x) = \sqrt{\frac{2}{\pi}}\frac{x^2}{a^3}\exp\left(\frac{-x^2}{2a^2}\right)$$

It has one scale parameter which is proportional to the square root of the temperature and inversely proportional to the mass of the particles.

The Maxwell distribution is implemented by the MaxwellDistribution class. It has one constructor that takes the value of the scale parameter. The code below creates a Maxwell distribution with scale parameter equal to 3:

C#
var maxwell = new MaxwellDistribution(3.0);

MaxwellDistribution has one static (Shared in Visual Basic) method, Sample, which generates a random sample using a user-supplied uniform random number generator. The second parameter is the scale parameter of the distribution that is to be sampled.

C#
var random = new MersenneTwister();
double sample = MaxwellDistribution.Sample(random, 3.0);

For details of the properties and methods common to all continuous distribution classes, see the topic on continuous distributions..