Phase Space Density and the Distribution Function

An ensemble is a cloud of copies scattered across phase space — but a cloud needs a shape. How thick is it here, how thin there? The answer is a single function, the phase-space density ρ(q,p,t)\rho(q,p,t): the probability, per unit phase-space volume, of finding the system near the point (q,p)(q,p) at time tt. It is the mathematical incarnation of Gibbs's ensemble, the object that turns the vague picture of "many copies" into something you can integrate, differentiate, and evolve. Everything statistical mechanics predicts is a moment of ρ\rho. Want the mean energy, pressure, or magnetization? Weight the observable by ρ\rho and integrate over all of phase space — that is an ensemble average, and ρ\rho is the weight. Want the entropy? Feed ρ\rho into the Gibbs functional −kB ⁣∫ ⁣ρln⁡ρ-k_{\mathrm B}\!\int\!\rho\ln\rho. Want to know how the ensemble evolves? ρ\rho obeys its own equation of motion, Liouville's, which says it flows through phase space like an incompressible fluid — never created, never destroyed, only carried along by the Hamiltonian wind. This is why ρ\rho sits at the hinge of the whole subject. Downstream of it lies every ensemble: the microcanonical ρ\rho is a constant on an energy shell, the canonical density is ρ=e−βH/Z\rho = e^{-\beta H}/Z, and each is a stationary solution — a density that depends on the microstate only through its energy, so the flow leaves it unchanged. Upstream of it lies the deepest puzzle in the field: the exact ρ\rho never increases its entropy, yet real systems relax, because measurement is coarse and the fine filaments of ρ\rho blur. Learn to read ρ\rho and you can compute any equilibrium average, write down any ensemble, and see exactly where irreversibility hides.

Key takeaways
  • The phase-space density ρ(q,p,t)\rho(q,p,t) gives the probability per unit phase-space volume of finding the system near (q,p)(q,p); it is normalized so ∫ρ dΓ=1\int\rho\,\mathrm d\Gamma=1.
  • Every prediction is a moment of ρ\rho: the ensemble average is ⟨A⟩=∫A(q,p) ρ dΓ\langle A\rangle=\int A(q,p)\,\rho\,\mathrm d\Gamma.
  • Equilibrium densities are stationary — they depend on the phase point only through conserved quantities, ρ=ρ(H)\rho=\rho(H), so {ρ,H}=0\{\rho,H\}=0.
  • The Gibbs entropy is a functional of ρ\rho: S=−kB ⁣∫ρln⁡ρ dΓS=-k_{\mathrm B}\!\int\rho\ln\rho\,\mathrm d\Gamma which is conserved under Liouville evolution.
  • ρ\rho evolves by Liouville's equation and flows like an incompressible fluid — the fine-grained entropy is constant; relaxation appears only after coarse-graining.
  • Key idea: the phase-space density ρ\rho is the ensemble made concrete; all averages, all entropies, and all ensembles are read off it, and its incompressible flow is Liouville's theorem.
The core insight

The phase-space density ρ(q,p,t)\rho(q,p,t) is the probability distribution of the ensemble over phase space. Every observable's ensemble average is an integral of it, the Gibbs entropy is a functional of it, and its incompressible Hamiltonian flow — governed by Liouville's theorem — determines its evolution.

Where this lives today

The phase-space density is the quantity that plasma physics, astrophysics, and beam physics actually solve for. A galaxy's stars, a fusion plasma's ions, and a particle accelerator's beam are all described by a distribution function f(q,p,t)f(q,p,t) obeying a Liouville-type equation (the collisionless Boltzmann or Vlasov equation), and predicting their behaviour means evolving ρ\rho across six-dimensional phase space — a routine, if heavy, numerical task on modern supercomputers. Its quantum descendant is everywhere in current physics. The quantum density operator ρ^\hat{\rho} generalizes the classical phase-space density ρ\rho, and the Wigner function represents it back on the classical (q,p)(q,p) plane as a quasi-probability that can go negative — a signature of genuinely quantum behaviour now measured routinely in quantum optics and superconducting-qubit experiments. Whenever an experiment reports the "state" of a quantum system as a tomographic reconstruction, it is measuring the quantum version of the object this article introduces.

The physical picture

Return to the imagined crowd of copies, one dot per microstate consistent with what we know. Where the dots are dense, the system is likely to be found; where they thin out, it is unlikely. The phase-space density ρ\rho is exactly that local dot-density, smoothed into a continuous function. It is a probability cloud draped over the 6N6N-dimensional phase space, and its total "weight" is one — the system is somewhere. The first figure shows the idea in the one plane you can draw: a probability hill over the (q,p)(q,p) plane. Its height at each point is ρ\rho; averaging any quantity means weighting it by this hill and summing.

Figure
The phase-space density is a probability hill over the (q,p) plane
q p ρ(q,p) — height = probability density contours of constant ρ ⟨A⟩ = ∫ A(q,p) ρ(q,p) dΓ — weight the observable by the hill

The hill is not frozen. It is carried by the Hamiltonian flow, and Liouville's theorem constrains that motion in a remarkable way: the hill can slide, tilt, stretch, and shear, but the density measured moving with the flow never changes. Picture a dye dropped into a swirling but incompressible fluid — the blob distorts into ever-finer tendrils, yet at every instant its local concentration, followed along a streamline, is exactly what it started as. That is ρ\rho under Hamiltonian flow, and it is the geometric content of dρ/dt=0\mathrm d\rho/\mathrm dt=0.

Figure
Liouville flow: the density is constant along streamlines while the blob filaments
t = 0: compact blob later: sheared, same ρ along it much later: fine filaments dρ/dt = 0 along trajectories — fine-grained entropy is frozen a coarse measurement sees the filaments blur to a smooth stationary ρ — that is where entropy rises

Equilibrium is the special density the flow leaves alone: one that depends on the phase point only through a conserved quantity, above all the energy, so that it is uniform along every trajectory. Such a ρ=ρ(H)\rho=\rho(H) has vanishing Poisson bracket with HH and hence no time dependence — and these are exactly the ensembles. The microcanonical ρ\rho is a constant on an energy shell; the canonical ρ\rho is ∝e−βH\propto e^{-\beta H}. The whole ensemble zoo is just the stationary solutions of the density's equation of motion.

The core equations

The phase-space density is a normalized probability distribution over the whole 6N6N-dimensional phase space:

∫ρ(q,p,t) dΓ=1,dΓ=∏i=13Ndqi dpi(1)\int \rho(q,p,t)\,\mathrm d\Gamma=1,\qquad \mathrm d\Gamma=\prod_{i=1}^{3N}\mathrm dq_i\,\mathrm dp_i \qquad (1)

where: ρ\rho — probability per unit phase-space volume; dΓ\mathrm d\Gamma — the phase-space volume element. Normalization says the system occupies some microstate with certainty; ρ\rho itself has units of inverse phase-space volume, so that ρ dΓ\rho\,\mathrm d\Gamma is a dimensionless probability. Its reason for existing is the ensemble average — every macroscopic prediction is ρ\rho-weighted:

⟨A⟩=∫A(q,p) ρ(q,p,t) dΓ(2)\langle A\rangle=\int A(q,p)\,\rho(q,p,t)\,\mathrm d\Gamma \qquad (2)

where: A(q,p)A(q,p) — any phase-space observable (energy, pressure, a density profile). Read Eq. (2) as "average AA over the cloud": regions where ρ\rho is large count more. This is the operational meaning of the ensemble, and it is linear in both AA and ρ\rho. The entropy of the ensemble is a functional of ρ\rho — the Gibbs entropy, the continuous cousin of −kB∑piln⁡pi-k_{\mathrm B}\sum p_i\ln p_i:

S=−kB∫ρln⁡ρ dΓ(3)S=-k_{\mathrm B}\int\rho\ln\rho\,\mathrm d\Gamma \qquad (3)

where: The integrand −ρln⁡ρ-\rho\ln\rho is largest where ρ\rho is neither extremely small nor concentrated at a single point; spreading the probability over more microstates generally increases the entropy. A sharply peaked ρ\rho (much knowledge) has low entropy; a broad ρ\rho (much ignorance) has high entropy. On a uniform microcanonical ρ=1/Ω\rho=1/\Omega this reduces to S=kBln⁡ΩS=k_{\mathrm B}\ln\Omega, tying Gibbs to Boltzmann. Equilibrium densities are the stationary ones — no explicit time dependence — which forces them to depend on phase-space coordinates only through conserved quantities:

∂ρ∂t=0 ⟺ ρ=ρ(H),{ρ,H}=0(4)\frac{\partial\rho}{\partial t}=0\ \Longleftrightarrow\ \rho=\rho(H),\qquad \{\rho,H\}=0 \qquad (4)

where: { ⋅ , ⋅ }\{\,\cdot\,,\,\cdot\,\} — the Poisson bracket. Any function of the Hamiltonian is constant along trajectories (energy is conserved), so its bracket with HH vanishes and the flow cannot change it. This is the criterion that selects the equilibrium ensembles, developed fully in Liouville's Theorem. The two flagship stationary densities are exactly the microcanonical and canonical ensembles:

ρmc∝δ(H−E),ρcan=e−βHZ(5)\rho_{\text{mc}}\propto\delta(H-E),\qquad \rho_{\text{can}}=\frac{e^{-\beta H}}{Z} \qquad (5)

where: ρmc\rho_{\text{mc}} — uniform on the energy shell H=EH=E; ρcan\rho_{\text{can}} — the Boltzmann-weighted density with normalizer Z=∫e−βH dΓZ=\int e^{-\beta H}\,\mathrm d\Gamma. Both are functions of HH alone, so both are stationary — they are the "shapes" the Hamiltonian flow can hold fixed forever. Finally, the evolution of a non-equilibrium ρ\rho is governed by the Liouville equation — the continuity equation for probability in phase space:

dρdt=∂ρ∂t+{ρ,H}=0(6)\frac{\mathrm d\rho}{\mathrm dt}=\frac{\partial\rho}{\partial t}+\{\rho,H\}=0 \qquad (6)

where: the total derivative follows the flow. Because probability is conserved and the flow is divergence-free (from Phase Space), ρ\rho obeys a source-free continuity equation, and the density measured moving with a trajectory is constant. This is Liouville's theorem for ρ\rho, the launching point for Liouville Equation.

Derivation AEvery average is a moment of ρ\rho, and standard equilibrium ensembles satisfy ρ=ρ(H)\rho = \rho(H)

This is the article's owned structural result, packaging the two facts that make ρ\rho the master object: that averages are its moments (so the description is complete), and that stationarity forces ρ\rho to be a function of the Hamiltonian (so the equilibrium ensembles are dictated, not chosen). The strategy is to write the ensemble average as a ρ\rho-weighted integral, confirm it is properly normalized, then impose ∂tρ=0\partial_t\rho=0 and show via the Poisson bracket that only densities depending on conserved quantities survive.

Step 1. Define the average of any observable by Eq. (2). Normalization Eq. (1) guarantees ⟨1⟩=∫ρ dΓ=1\langle 1\rangle=\int\rho\,\mathrm d\Gamma=1, so probabilities are consistent and ⟨A⟩\langle A\rangle is a genuine mean. Why: the entire predictive content of the ensemble lives in these moments of ρ\rho; if we can write ρ\rho, we can compute anything measurable.

Step 2. Impose stationarity. Liouville's equation ∂tρ=−{ρ,H}\partial_t\rho=-\{\rho,H\} means ∂tρ=0\partial_t\rho=0 requires {ρ,H}=0\{\rho,H\}=0. For any differentiable function ρ=f(H)\rho=f(H) the bracket is {f(H),H}=f′(H){H,H}=0\{f(H),H\}=f'(H)\{H,H\}=0. Why: energy is conserved along the flow, so a density built purely from energy is carried unchanged — it is automatically an equilibrium solution.

Step 3. Read off the ensembles. The uniform-on-the-shell choice ρ∝δ(H−E)\rho\propto\delta(H-E) and the exponential choice ρ∝e−βH\rho\propto e^{-\beta H} are both functions of HH, hence both stationary — they are the microcanonical and canonical densities of Eq. (5). Why: the equilibrium ensembles are not independent postulates; they are the stationary solutions of the density's equation of motion, and any ρ(H)\rho(H) is a candidate equilibrium. *Three results underpin the derivation: normalization gives ⟨1⟩=1\langle 1\rangle=1 for any properly normalized ρ\rho; the bracket identity {f(H),H}=0\{f(H),H\}=0 holds symbolically for any function of HH; and the convective identity v⋅∇ρ={ρ,H}v\cdot\nabla\rho=\{\rho,H\} connects the Poisson-bracket form of Liouville's equation to the familiar fluid-continuity picture.*

Go deeper · Derivation B · 1 minEquipartition from the Maxwell–Boltzmann density
Derivation BEquipartition from the Maxwell–Boltzmann density

Here we put ρ\rho to work on the single most important classical density and extract a cornerstone result — the equipartition of energy — by direct integration. The goal is to show that the canonical density ρ∝e−βH\rho\propto e^{-\beta H}, restricted to the momentum of one particle, is a Gaussian, and that computing ⟨p2/2m⟩\langle p^2/2m\rangle as a moment of that Gaussian yields exactly 12kBT\tfrac12 k_{\mathrm B}T per degree of freedom. This both demonstrates the machinery of Eq. (2) and delivers the 32kBT\tfrac32 k_{\mathrm B}T mean kinetic energy of a gas atom.

Step 1. For a free particle the canonical momentum density is ρ(p)∝e−βp2/2m\rho(p)\propto e^{-\beta p^2/2m} — a Gaussian. Its normalizer is ∫−∞∞e−βp2/2m dp=2πm/β\int_{-\infty}^{\infty}e^{-\beta p^2/2m}\,\mathrm dp=\sqrt{2\pi m/\beta}. Why: the Hamiltonian is quadratic in momentum, so the Boltzmann factor is a Gaussian, and the whole calculation reduces to standard Gaussian integrals.

Step 2. Compute the mean kinetic energy of one component as a moment of ρ\rho:

⟨p22m⟩=∫p22m e−βp2/2m dp∫e−βp2/2m dp=12β=12kBT(7)\left\langle\frac{p^2}{2m}\right\rangle=\frac{\int\frac{p^2}{2m}\,e^{-\beta p^2/2m}\,\mathrm dp}{\int e^{-\beta p^2/2m}\,\mathrm dp}=\frac{1}{2\beta}=\frac12 k_{\mathrm B}T \qquad (7)

Why: the ratio of Gaussian moments gives ⟨p2⟩=m/β\langle p^2\rangle=m/\beta, so each quadratic momentum term stores exactly 12kBT\tfrac12 k_{\mathrm B}T — equipartition, derived directly as a moment of the phase-space density.

Step 3. Sum the three Cartesian components: ⟨12m(px2+py2+pz2)⟩=32kBT\langle\tfrac{1}{2m}(p_x^2+p_y^2+p_z^2)\rangle=\tfrac32 k_{\mathrm B}T. Why: three independent quadratic degrees of freedom each contribute 12kBT\tfrac12 k_{\mathrm B}T, giving the familiar mean translational kinetic energy of a gas atom — and, by symmetry, ⟨p⟩=0\langle p\rangle=0, since the Gaussian is even. *The key symbolic results are: ⟨p2/2m⟩=1/(2β)\langle p^2/2m\rangle=1/(2\beta) per component; multiplying by three gives 3/(2β)=32kBT3/(2\beta)=\tfrac{3}{2}k_{\mathrm B}T; the Gaussian normalizer is 2πm/β\sqrt{2\pi m/\beta}; and ⟨p⟩=0\langle p\rangle=0 because the integrand is odd.*

Limiting cases

CaseDensity ρ\rhoMeaning
Complete knowledgeρ=δ(Γ−Γ0)\rho=\delta(\Gamma-\Gamma_0)one exact microstate; entropy →−∞\to-\infty (limiting idealization)
Microcanonicalρ∝δ(H−E)\rho\propto\delta(H-E)uniform on the energy shell; S=kBln⁡ΩS=k_{\mathrm B}\ln\Omega
Canonicalρ∝e−βH\rho\propto e^{-\beta H}Boltzmann-weighted; the everyday equilibrium density
Coarse-grained late timeρ→ρeq(H)\rho\to\rho_{\text{eq}}(H)filaments blur; entropy rises to its equilibrium value

Worked examples

1 · The mean speed of an air molecule from ρ (confidence builder)

Use the Maxwell–Boltzmann phase-space density to find the root-mean-square speed of a nitrogen molecule (m=4.65×10−26 kgm=4.65\times10^{-26}\,\mathrm{kg}) in air at T=300 KT=300\,\mathrm K.

Step 1. From Derivation 2, the mean kinetic energy is ⟨12mv2⟩=32kBT\langle\tfrac12 mv^2\rangle=\tfrac32 k_{\mathrm B}T — a moment of ρ\rho, no new integral needed.

Step 2. Solve for the mean-square speed: ⟨v2⟩=3kBTm=3(1.381×10−23)(300)4.65×10−26=2.67×105 m2/s2\langle v^2\rangle=\dfrac{3k_{\mathrm B}T}{m}=\dfrac{3(1.381\times10^{-23})(300)}{4.65\times10^{-26}}=2.67\times10^{5}\,\mathrm{m^2/s^2}.

Step 3. Root-mean-square speed: vrms=⟨v2⟩=517 m/sv_{\text{rms}}=\sqrt{\langle v^2\rangle}=\boxed{517\ \mathrm{m/s}} — faster than sound, as it must be, since sound is carried by these very molecules.

Step 4. Sanity: the thermal energy per molecule is 32kBT=6.2×10−21 J≈0.039 eV\tfrac32 k_{\mathrm B}T=6.2\times10^{-21}\,\mathrm J\approx0.039\,\mathrm{eV}, the familiar ∼ ⁣1/40 eV\sim\!1/40\,\mathrm{eV} room-temperature scale. Every number here is a moment of the same phase-space density ρ∝e−βH\rho\propto e^{-\beta H}.

2 · The entropy cost of localizing a particle (exam level)

A gas atom's position is initially known only to be somewhere in a volume V1V_1 (uniform density). It is then compressed isothermally so it is confined to V2<V1V_2<V_1. Using the Gibbs entropy of ρ\rho, find the change in entropy and relate it to the heat exchanged.

Step 1. For a uniform spatial density ρ=1/V\rho=1/V over the accessible volume, the configurational contribution to Gibbs entropy is S=−kB ⁣∫1Vln⁡1V d3q=kBln⁡VS=-k_{\mathrm B}\!\int\frac1V\ln\frac1V\,\mathrm d^3q=k_{\mathrm B}\ln V (the momentum part is unchanged at fixed TT).

Step 2. Change on compression: ΔS=kBln⁡V2−kBln⁡V1=kBln⁡V2V1\Delta S=k_{\mathrm B}\ln V_2-k_{\mathrm B}\ln V_1=k_{\mathrm B}\ln\dfrac{V_2}{V_1}. Since V2<V1V_2<V_1, ΔS<0\Delta S<0 — localizing the particle lowers its entropy.

Step 3. Put in numbers for a tenfold compression, V2/V1=1/10V_2/V_1=1/10: ΔS=kBln⁡(0.1)=−2.30 kB=−3.18×10−23 J/K\Delta S=k_{\mathrm B}\ln(0.1)=-2.30\,k_{\mathrm B}=-3.18\times10^{-23}\,\mathrm{J/K} per atom.

Step 4. For N=6.022×1023N=6.022\times10^{23} atoms (one mole), ΔS=−NkBln⁡10=−19.1 J/K\Delta S=-Nk_{\mathrm B}\ln10=-19.1\,\mathrm{J/K}, and the heat expelled to the bath is Q=TΔS=−5.7 kJQ=T\Delta S=-5.7\,\mathrm{kJ}. This is exactly the isothermal-compression entropy nRln⁡(V2/V1)nR\ln(V_2/V_1) of elementary thermodynamics — recovered here purely as the change in the Gibbs functional of ρ\rho.

Origins · 1 minJames Clerk Maxwell and how this was discovered
JC
James Clerk Maxwell
1831–1879 · Cambridge and Aberdeen

Maxwell opened the statistical era of physics in 1860 by asking a radically new question: not how a single molecule moves, but how molecular velocities are distributed. His answer — the Maxwell distribution, the momentum-space face of the density ρ∝e−βH\rho\propto e^{-\beta H} used throughout this article — was the first time a physical law was stated as a probability distribution rather than a deterministic trajectory. He derived it from a symmetry argument (the three velocity components are independent and isotropic) that still feels startlingly modern. Maxwell also invented the demon that bears his name to probe the statistical nature of the second law, and his kinetic theory, refined by Boltzmann and Gibbs, became the density-based statistical mechanics we use today. He is, of course, equally the architect of electromagnetism.

History
1859
— Maxwell, inspired by the statistics of errors, proposes distributing molecular velocities.
1860
— Maxwell publishes the velocity distribution, the first statistical law of physics.
1872
— Boltzmann writes a transport equation for the single-particle distribution function ff.
1902
— Gibbs formalizes the full phase-space density ρ\rho and the ensemble average as an integral of it.
1932
— von Neumann introduces the density operator, the quantum analogue of ρ\rho.

Going further

Texts. Pathria & Beale, Statistical Mechanics, 3rd ed., §2.1–2.2 · Kardar, Statistical Physics of Particles, §3.1–3.3 · Reif, Fundamentals of Statistical and Thermal Physics, §7 · Landau & Lifshitz, Statistical Physics Part 1, §1–4 · Balescu, Equilibrium and Nonequilibrium Statistical Mechanics, Ch. 2. Key results collected here for reference: normalization ⟨1⟩=1\langle1\rangle=1; Maxwell–Boltzmann moments ⟨p2/2m⟩=12kBT\langle p^2/2m\rangle=\tfrac12 k_{\mathrm B}T per component (Gaussian integrals), ⟨p⟩=0\langle p\rangle=0, normalizer 2πm/β\sqrt{2\pi m/\beta}; stationarity criterion {ρ(H),H}=0\{\rho(H),H\}=0; Gibbs entropy of a uniform density S=kBln⁡VS=k_{\mathrm B}\ln V; worked numbers: vrms=517 m/sv_{\text{rms}}=517\,\mathrm{m/s} for N2_2 at 300 K, ΔS=−NkBln⁡10=−19.1 J/K\Delta S=-Nk_{\mathrm B}\ln10=-19.1\,\mathrm{J/K} for a tenfold isothermal compression of a mole. Constant used: kB=1.380649×10−23 J/Kk_{\mathrm B}=1.380649\times10^{-23}\,\mathrm{J/K}.

Prerequisites. Phase Space · Microstates and Macrostates · Statistical Ensembles. Leads to. Liouville's Theorem · Liouville Equation and the Liouville Operator · Gibbs Entropy · Fundamental Postulate of Equal A Priori Probabilities.

Is ρ a property of the system, or of my knowledge about it?

It is a property of your knowledge — an epistemic object, not something you could measure on a single copy. A lone system is in one definite microstate; ρ\rho describes the distribution of microstates across the ensemble of copies consistent with what you know. Prepare the system with more information (fix more constraints) and ρ\rho sharpens; know less and it broadens. This is why the Gibbs entropy −kB ⁣∫ρln⁡ρ-k_{\mathrm B}\!\int\rho\ln\rho measures ignorance: a delta-function ρ\rho (complete knowledge) has minimal entropy, a broad ρ\rho (little knowledge) has large entropy. The density is the mathematical form of "what we know about the microstate."

What's the difference between ρ here and the single-particle distribution function f in kinetic theory?

They live in different spaces and answer different questions. The full phase-space density ρ(q1,p1,…,q3N,p3N,t)\rho(q_1,p_1,\dots,q_{3N},p_{3N},t) lives in the 6N6N-dimensional phase space of the whole system and contains all correlations between particles. The single-particle distribution f(q,p,t)f(q,p,t) of kinetic theory lives in the 66-dimensional phase space of one particle and is obtained by integrating ρ\rho over all the other particles. Going from ρ\rho to ff throws away inter-particle correlations, which is why ff obeys the approximate Boltzmann transport equation (with a collision term) rather than the exact, correlation-preserving Liouville equation. ρ\rho is exact and reversible; ff is reduced and can show irreversibility.

Why is any function of H automatically an equilibrium density?

Because energy is conserved along every trajectory. Equilibrium means the density does not change in time, ∂tρ=0\partial_t\rho=0, and Liouville's equation turns this into {ρ,H}=0\{\rho,H\}=0. If ρ=f(H)\rho=f(H) for some function ff, then {f(H),H}=f′(H){H,H}=0\{f(H),H\}=f'(H)\{H,H\}=0 automatically, since a quantity always Poisson-commutes with itself. Physically: as the phase point flows along a trajectory of fixed energy, a density built only from energy takes the same value all along that trajectory, so nothing about it changes with time. This is exactly why the microcanonical (ρ∝δ(H−E)\rho\propto\delta(H-E)) and canonical (ρ∝e−βH\rho\propto e^{-\beta H}) densities are stationary — both are functions of HH alone.

If ρ never changes its entropy under Liouville flow, where does the second law come from?

From coarse-graining, and this is the single subtlest point in the foundations. The exact (fine-grained) density ρ\rho has a Gibbs entropy that is provably constant — Liouville flow just carries ρ\rho around without changing its values, so −kB ⁣∫ρln⁡ρ-k_{\mathrm B}\!\int\rho\ln\rho is frozen. But ρ\rho stretches into filaments finer than any real measurement can resolve. When you smooth ρ\rho over the resolution of your instrument (coarse-graining), the smoothed density spreads out and its entropy increases toward the equilibrium value kBln⁡Ωk_{\mathrm B}\ln\Omega. The second law is a statement about this coarse-grained entropy, not the exact one. Nothing about the microscopic dynamics is irreversible; the irreversibility is in the unavoidable loss of fine detail.

How do I get the microcanonical or canonical ensemble as a "density"? A delta function isn't a normal function.

The microcanonical density ρ∝δ(H−E)\rho\propto\delta(H-E) is indeed a distribution (a generalized function), concentrated on the (6N−1)(6N-1)-dimensional energy shell — it is normalized by dividing by the shell "area" ∫δ(H−E) dΓ\int\delta(H-E)\,\mathrm d\Gamma, which is essentially Ω(E)\Omega(E). The canonical density ρ=e−βH/Z\rho=e^{-\beta H}/Z is an ordinary smooth function, spread over all energies but exponentially suppressed at high energy, normalized by Z=∫e−βH dΓZ=\int e^{-\beta H}\,\mathrm d\Gamma. Both are legitimate probability densities on phase space; both are functions of HH and therefore stationary. The delta function is the mathematically clean way to say "uniform on the shell, zero off it."

Does ρ have a quantum version, or is this purely classical?

It has a direct quantum version: the density operator (or density matrix) ρ^\hat\rho, introduced by von Neumann in 1932. Where the classical ρ\rho assigns a probability to each phase-space point, ρ^\hat\rho assigns a probability distribution over quantum states, and ensemble averages become ⟨A⟩=Tr(ρ^A^)\langle A\rangle=\mathrm{Tr}(\hat\rho\hat A) — the trace playing the role of ∫⋯dΓ\int\cdots\mathrm d\Gamma. The quantum Liouville (von Neumann) equation iℏ ∂tρ^=[H^,ρ^]i\hbar\,\partial_t\hat\rho=[\hat H,\hat\rho] replaces the Poisson bracket with a commutator. One can even map ρ^\hat\rho back onto the classical (q,p)(q,p) plane as the Wigner function, a quasi-probability that can be negative — a purely quantum feature with no classical counterpart. So ρ\rho is the classical member of a family that runs all the way to quantum statistical mechanics.

Before this

Where this leads