Here’s a fascinating example from statistical mechanics: the Maxwell-Boltzmann distribution of particle speeds in an ideal gas.
This distribution describes the probable speeds of particles at a given temperature, which is central to understanding gas behavior in thermodynamics.
Problem: Plotting the Maxwell-Boltzmann Speed Distribution
The Maxwell-Boltzmann distribution is a probability distribution for the speed $( v )$ of particles in an ideal gas at a certain temperature $( T )$. Given:
- Temperature $( T )$ of the gas,
- Particle mass $( m )$,
we can determine the likelihood of finding particles moving at different speeds.
The probability density function of the Maxwell-Boltzmann speed distribution is given by:
$$
f(v) = 4\pi \left( \frac{m}{2 \pi k_B T} \right)^{3/2} v^2 \exp \left( -\frac{mv^2}{2k_B T} \right)
$$
- $( v )$ is the particle speed,
- $( m )$ is the mass of each particle,
- $( T )$ is the absolute temperature,
- $( k_B )$ is the Boltzmann constant.
Goal
- Calculate the Maxwell-Boltzmann distribution for speeds.
- Plot the distribution to observe how it varies with temperature.
Python Code
Below is the $Python$ code to compute and plot the Maxwell-Boltzmann distribution for a given temperature and particle mass:
1 | import numpy as np |
Explanation of the Code
- Function Definition:
- We define a function
maxwell_boltzmann(v, T, m)to calculate the probability density $ f(v) $ at different speeds $( v )$ for a given temperature $( T )$ and particle mass $( m )$.
- We define a function
- Speed Range:
- We create an array
vrepresenting a range of speeds up to around $2000$ m/s, which covers the typical speeds of nitrogen molecules at room temperature.
- We create an array
- Distribution Calculation:
- Using the
maxwell_boltzmannfunction, we compute $ f(v) $ for each speed inv.
- Using the
- Plotting:
- We plot $( v )$ on the $x$-axis and $ f(v) $ on the $y$-axis, giving a clear visualization of the speed distribution.
Visualization and Interpretation

The graph shows:
- Peak: The curve peaks at a specific speed, which represents the most probable speed of particles at this temperature.
- Spread: The distribution has a long tail, indicating some particles have higher speeds, though with decreasing probability.
- Temperature Dependence: As temperature increases (not shown here but if varied), the peak shifts to higher speeds, indicating faster-moving particles.
Insights from the Maxwell-Boltzmann Distribution
- Temperature Effect: Higher temperatures lead to broader, more spread-out distributions, as particles move faster on average.
- Statistical Behavior: The distribution embodies the statistical nature of molecular motion, providing a basis for understanding macroscopic gas properties, like pressure and temperature.
- Applications: Maxwell-Boltzmann statistics are crucial in fields like chemistry, thermodynamics, and kinetic theory, helping explain diffusion rates, reaction kinetics, and energy transfer.
This visualization brings out the fundamental principles of statistical mechanics and demonstrates how particle motion distributions are governed by temperature.








