We take a very simple situation in which each atom can be approximated as a two state system. The thermal energy is so low that the atom is in the ground state. In this ground state, the atom is assumed to have no net orbital angular momentum but only one unpaired electron to give it a spin of the half. In the presence of an external magnetic field, the ground state will split into two states having an energy difference proportional to the applied field. The spin of the unpaired electron is parallel to the field in the higher energy state and anti-parallel in the lower one.
A density matrix, , is a matrix that describes a quantum system in a mixed state, a statistical ensemble of several quantum states (here several similar 2-state atoms). This should be contrasted with a single state vector that describes a quantum system in a pure state. The expectation value of a measurement, , over the ensemble is . In terms of a complete set of states, , one can write
Von Neumann's equation tells us how the density matrix evolves with time.
In equilibrium,
one has , and the allowed density matrices are 
The canonical ensemble has 
where
For the 2-state system, we can write
Here  is the gyromagnetic ratio.
Hence , and
From which