# Radial distribution function

In statistical mechanics, the radial distribution function, (or pair correlation function) $g(r)$ in a system of particles (atoms, molecules, colloids, etc.), describes how density varies as a function of distance from a reference particle.
If a given particle is taken to be at the origin O, and if $\rho =N/V$ is the average number density of particles, then the local time-averaged density at a distance $r$ from O is $\rho g(r)$. This simplified definition holds for a homogeneous and isotropic system. A more general case will be considered below.
In simplest terms it is a measure of the probability of finding a particle at a distance of $r$ away from a given reference particle, relative to that for an ideal gas. The general algorithm involves determining how many particles are within a distance of $r$ and $r+dr$ away from a particle. This general theme is depicted to the right, where the red particle is our reference particle, and the blue particles are those whose centers are within the circular shell, dotted in orange.
The radial distribution function is usually determined by calculating the distance between all particle pairs and binning them into a histogram. The histogram is then normalized with respect to an ideal gas, where particle histograms are completely uncorrelated. For three dimensions, this normalization is the number density of the system $(\rho )$ multiplied by the volume of the spherical shell, which symbolically can be expressed as $\rho \,4\pi r^{2}dr$.
Given a potential energy function, the radial distribution function can be computed either via computer simulation methods like the Monte Carlo method, or via the Ornstein–Zernike equation, using approximative closure relations like the Percus–Yevick approximation or the hypernetted-chain theory. It can also be determined experimentally, by radiation scattering techniques or by direct visualization for large enough (micrometer-sized) particles via traditional or confocal microscopy.
The radial distribution function is of fundamental importance since it can be used, using the Kirkwood–Buff solution theory, to link the microscopic details to macroscopic properties. Moreover, by the reversion of the Kirkwood–Buff theory, it is possible to attain the microscopic details of the radial distribution function from the macroscopic properties. The radial distribution function may also be inverted to predict the potential energy function using the Ornstein–Zernike equation or structure-optimized potential refinement.

## Definition

Consider a system of $N$ particles in a volume $V$ (for an average number density $\rho =N/V$) and at a temperature $T$ (let us also define $\textstyle \beta ={\frac {1}{kT}}$; $k$ is the Boltzmann constant). The particle coordinates are $\mathbf {r} _{i}$, with $\textstyle i=1,\,\ldots ,\,N$. The potential energy due to the interaction between particles is $\textstyle U_{N}(\mathbf {r} _{1}\,\ldots ,\,\mathbf {r} _{N})$ and we do not consider the case of an externally applied field.
The appropriate averages are taken in the canonical ensemble $(N,V,T)$, with $\textstyle Z_{N}=\int \cdots \int \mathrm {e} ^{-\beta U_{N}}\mathrm {d} \mathbf {r} _{1}\cdots \mathrm {d} \mathbf {r} _{N}$ the configurational integral, taken over all possible combinations of particle positions. The probability of an elementary configuration, namely finding particle 1 in $\textstyle \mathrm {d} \mathbf {r} _{1}$, particle 2 in $\textstyle \mathrm {d} \mathbf {r} _{2}$, etc. is given by
| $P^{(N)}(\mathbf {r} _{1},\ldots ,\mathbf {r} _{N})\,\mathrm {d} \mathbf {r} _{1}\cdots \mathrm {d} \mathbf {r} _{N}={\frac {\mathrm {e} ^{-\beta U_{N}}}{Z_{N}}}\,\mathrm {d} \mathbf {r} _{1}\cdots \mathrm {d} \mathbf {r} _{N}\,$. | (1) |
The total number of particles is huge, so that $P^{(N)}$ in itself is not very useful. However, one can also obtain the probability of a reduced configuration, where the positions of only $n<N$ particles are fixed, in $\textstyle \mathbf {r} _{1}\,\ldots ,\,\mathbf {r} _{n}$, with no constraints on the remaining $N-n$ particles. To this end, one has to integrate (1) over the remaining coordinates $\mathbf {r} _{n+1}\,\ldots ,\,\mathbf {r} _{N}$:
    $P^{(n)}(\mathbf {r} _{1},\ldots ,\mathbf {r} _{n})={\frac {1}{Z_{N}}}\int \cdots \int \mathrm {e} ^{-\beta U_{N}}\,\mathrm {d} ^{3}\mathbf {r} _{n+1}\cdots \mathrm {d} ^{3}\mathbf {r} _{N}\,$.
If the particles are non-interacting, in the sense that the potential energy of each particle does not depend on any of the other particles, U$_N$(r$_1$, …, r$_N$)=∑$_{i=1}$$^N$U$_1$(r$_i$){\textstyle U_{N}(\mathbf {r} _{1}, \dots , \mathbf {r} _{N})=\sum _{i=1}^{N}U_{1}(\mathbf {r} _{i})}, then the partition function factorizes, and the probability of an elementary configuration decomposes with independent arguments to a product of single particle probabilities, ${\begin{aligned}Z_{N}&=\prod _{i=1}^{N}\int \mathrm {d} ^{3}\mathbf {r} _{i}e^{-\beta U_{1}}=Z_{1}^{N}\\P^{(n)}(\mathbf {r} _{1},\dots ,\mathbf {r} _{n})&=P^{(1)}(\mathbf {r} _{1})\cdots P^{(1)}(\mathbf {r} _{n})\end{aligned}}$
Note how for non-interacting particles the probability is symmetric in its arguments. This is not true in general, and the order in which the positions occupy the argument slots of $P^{(n)}$matters. Given a set of positions, the way that the $N$ particles can occupy those positions is $N!$ The probability that those positions ARE occupied is found by summing over all configurations in which a particle is at each of those locations. This can be done by taking every permutation, $\pi$, in the symmetric group on $N$ objects, $S_{N}$, to write ∑$_{π∈SN}$P$^{(N)}$(r$_{π(1)}$, …, r$_{π(N)}$){\textstyle \sum _{\pi \in S_{N}}P^{(N)}(\mathbf {r} _{\pi (1)}, \ldots , \mathbf {r} _{\pi (N)})}. For fewer positions, we integrate over extraneous arguments, and include a correction factor to prevent overcounting,${\begin{aligned}\rho ^{(n)}(\mathbf {r} _{1},\ldots ,\mathbf {r} _{n})&={\frac {1}{(N-n)!}}\left(\prod _{i=n+1}^{N}\int \mathrm {d} ^{3}\mathbf {r} _{i}\right)\sum _{\pi \in S_{N}}P^{(N)}(\mathbf {r} _{\pi (1)},\ldots ,\mathbf {r} _{\pi (N)})\\\end{aligned}}$This quantity is called the n-particle density function. For indistinguishable particles, one could permute all the particle positions, $\forall i,\mathbf {r} _{i}\rightarrow \mathbf {r} _{\pi (i)}$, without changing the probability of an elementary configuration, $P(\mathbf {r} _{\pi (1)},\dots ,\mathbf {r} _{\pi (N)})=P(\mathbf {r} _{1},\dots ,\mathbf {r} _{N})$, so that the n-particle density function reduces to ${\begin{aligned}\rho ^{(n)}(\mathbf {r} _{1},\ldots ,\mathbf {r} _{n})&={\frac {N!}{(N-n)!}}P^{(n)}(\mathbf {r} _{1},\ldots ,\mathbf {r} _{n})\end{aligned}}$Integrating the n-particle density gives the permutation factor $_{N}P_{n}$, counting the number of ways one can sequentially pick particles to place at the $n$ positions out of the total $N$ particles. Now let's turn to how we interpret this functions for different values of $n$.
For $n=1$, we have the one-particle density. For a crystal it is a periodic function with sharp maxima at the lattice sites. For a non-interacting gas, it is independent of the position $\textstyle \mathbf {r} _{1}$ and equal to the overall number density, $\rho$, of the system. To see this first note that $U_{N}=\infty$ in the volume occupied by the gas, and 0 everywhere else. The partition function in this case is
    $Z_{N}=\prod _{i=1}^{N}\int \mathrm {d} ^{3}\mathbf {r} _{i}\ 1=V^{N}$
from which the definition gives the desired result
    $\rho ^{(1)}(\mathbf {r} )={\frac {N!}{(N-1)!}}{\frac {1}{V^{N}}}\prod _{i=2}^{N}\int \mathrm {d} ^{3}\mathbf {r} _{i}1={\frac {N}{V}}=\rho .$
In fact, for this special case every n-particle density is independent of coordinates, and can be computed explicitly${\begin{aligned}\rho ^{(n)}(\mathbf {r} _{1},\dots ,\mathbf {r} _{n})&={\frac {N!}{(N-n)!}}{\frac {1}{V^{N}}}\prod _{i=n+1}^{N}\int \mathrm {d} ^{3}\mathbf {r} _{i}1\\&={\frac {N!}{(N-n)!}}{\frac {1}{V^{n}}}\end{aligned}}$For $N\gg n$, the non-interacting n-particle density is approximately $\rho _{\text{non-interacting}}^{(n)}(\mathbf {r} _{1},\dots ,\mathbf {r} _{N})=\left(1-n(n-1)/2N+\cdots \right)\rho ^{n}\approx \rho ^{n}$. With this in hand, the n-point correlation function $g^{(n)}$ is defined by factoring out the non-interacting contribution, $\rho ^{(n)}(\mathbf {r} _{1},\ldots ,\,\mathbf {r} _{n})=\rho _{\text{non-interacting}}^{(n)}g^{(n)}(\mathbf {r} _{1}\,\ldots ,\,\mathbf {r} _{n})$Explicitly, this definition reads ${\begin{aligned}g^{(n)}(\mathbf {r} _{1},\ldots ,\,\mathbf {r} _{n})&={\frac {V^{N}}{N!}}\left(\prod _{i=n+1}^{N}{\frac {1}{V}}\!\!\int \!\!\mathrm {d} ^{3}\mathbf {r} _{i}\right){\frac {1}{Z_{N}}}\sum _{\pi \in S_{N}}e^{-\beta U(\mathbf {r} _{\pi (1)},\ldots ,\,\mathbf {r} _{\pi (N)})}\end{aligned}}$where it is clear that the n-point correlation function is dimensionless.

## Relations involving g(r)
### Structure factor

The second-order correlation function $g^{(2)}(\mathbf {r} _{1},\mathbf {r} _{2})$ is of special importance, as it is directly related (via a Fourier transform) to the structure factor of the system and can thus be determined experimentally using X-ray diffraction or neutron diffraction.
If the system consists of spherically symmetric particles, $g^{(2)}(\mathbf {r} _{1},\mathbf {r} _{2})$ depends only on the relative distance between them, $\mathbf {r} _{12}=\mathbf {r} _{2}-\mathbf {r} _{1}$. We will drop the sub- and superscript: $\textstyle g(\mathbf {r} )\equiv g^{(2)}(\mathbf {r} _{12})$. Taking particle 0 as fixed at the origin of the coordinates, $\textstyle \rho g(\mathbf {r} )d^{3}r=\mathrm {d} n(\mathbf {r} )$ is the average number of particles (among the remaining $N-1$) to be found in the volume $\textstyle d^{3}r$ around the position $\textstyle \mathbf {r}$.
We can formally count these particles and take the average via the expression $\textstyle {\frac {\mathrm {d} n(\mathbf {r} )}{d^{3}r}}=\langle \sum _{i\neq 0}\delta (\mathbf {r} -\mathbf {r} _{i})\rangle$, with $\textstyle \langle \cdot \rangle$ the ensemble average, yielding:
| $g(\mathbf {r} )={\frac {1}{\rho }}\langle \sum _{i\neq 0}\delta (\mathbf {r} -\mathbf {r} _{i})\rangle =V{\frac {N-1}{N}}\left\langle \delta (\mathbf {r} -\mathbf {r} _{1})\right\rangle$ | (5) |
where the second equality requires the equivalence of particles $\textstyle 1,\,\ldots ,\,N-1$. The formula above is useful for relating $g(\mathbf {r} )$ to the static structure factor $S(\mathbf {q} )$, defined by $\textstyle S(\mathbf {q} )=\langle \sum _{ij}\mathrm {e} ^{-i\mathbf {q} (\mathbf {r} _{i}-\mathbf {r} _{j})}\rangle /N$, since we have:
    ${\begin{aligned}S(\mathbf {q} )&=1+{\frac {1}{N}}\langle \sum _{i\neq j}\mathrm {e} ^{-i\mathbf {q} (\mathbf {r} _{i}-\mathbf {r} _{j})}\rangle =1+{\frac {1}{N}}\left\langle \int _{V}\mathrm {d} \mathbf {r} \,\mathrm {e} ^{-i\mathbf {q} \mathbf {r} }\sum _{i\neq j}\delta \left[\mathbf {r} -(\mathbf {r} _{i}-\mathbf {r} _{j})\right]\right\rangle \\&=1+{\frac {N(N-1)}{N}}\int _{V}\mathrm {d} \mathbf {r} \,\mathrm {e} ^{-i\mathbf {q} \mathbf {r} }\left\langle \delta (\mathbf {r} -\mathbf {r} _{1})\right\rangle ,\end{aligned}}$
and thus:
    $S(\mathbf {q} )=1+\rho \int _{V}\mathrm {d} \mathbf {r} \,\mathrm {e} ^{-i\mathbf {q} \mathbf {r} }g(\mathbf {r} )$, proving the Fourier relation alluded to above.
This equation is only valid in the sense of distributions, since $g(\mathbf {r} )$ is not normalized: $\textstyle \lim _{r\rightarrow \infty }g(\mathbf {r} )=1$, so that $\textstyle \int _{V}\mathrm {d} \mathbf {r} g(\mathbf {r} )$ diverges as the volume $V$, leading to a Dirac peak at the origin for the structure factor. Since this contribution is inaccessible experimentally we can subtract it from the equation above and redefine the structure factor as a regular function:
    $S'(\mathbf {q} )=S(\mathbf {q} )-\rho \delta (\mathbf {q} )=1+\rho \int _{V}\mathrm {d} \mathbf {r} \,\mathrm {e} ^{-i\mathbf {q} \mathbf {r} }[g(\mathbf {r} )-1]$.
Finally, we rename $S(\mathbf {q} )\equiv S'(\mathbf {q} )$ and, if the system is a liquid, we can invoke its isotropy:
| $S(q)=1+\rho \int _{V}\mathrm {d} \mathbf {r} \,\mathrm {e} ^{-i\mathbf {q} \mathbf {r} }[g(r)-1]=1+4\pi \rho {\frac {1}{q}}\int \mathrm {d} r\,r\,\mathrm {sin} (qr)[g(r)-1]$. | (6) |

### Compressibility equation

Evaluating (6) in $q=0$ and using the relation between the isothermal compressibility $\textstyle \chi _{T}$ and the structure factor at the origin yields the compressibility equation:
| $\rho kT\chi _{T}=kT\left({\frac {\partial \rho }{\partial p}}\right)=1+\rho \int _{V}\mathrm {d} \mathbf {r} \,[g(r)-1]$. | (7) |

### Potential of mean force

It can be shown that the radial distribution function is related to the two-particle potential of mean force $w^{(2)}(r)$ by:
| $g(r)=\exp \left[-{\frac {w^{(2)}(r)}{kT}}\right]$. | (8) |
In the dilute limit, the potential of mean force is the exact pair potential under which the equilibrium point configuration has a given $g(r)$.

### Energy equation

If the particles interact via identical pairwise potentials: $\textstyle U_{N}=\sum _{i>j=1}^{N}u(\left|\mathbf {r} _{i}-\mathbf {r} _{j}\right|)$, the average internal energy per particle is:$^{:Section2.5}$
| ${\frac {\left\langle E\right\rangle }{N}}={\frac {3}{2}}kT+{\frac {\left\langle U_{N}\right\rangle }{N}}={\frac {3}{2}}kT+{\frac {\rho }{2}}\int _{V}\mathrm {d} \mathbf {r} \,u(r)g(r,\rho ,T)$. | (9) |

### Pressure equation of state

Developing the virial equation yields the pressure equation of state:
| $p=\rho kT-{\frac {\rho ^{2}}{6}}\int _{V}\mathrm {d} \mathbf {r} \,rg(r,\rho ,T){\frac {\mathrm {d} u(r)}{\mathrm {d} r}}$. | (10) |

### Thermodynamic properties in 3D

The radial distribution function is an important measure because several key thermodynamic properties, such as potential energy and pressure can be calculated from it.
For a 3-D system where particles interact via pairwise potentials, the potential energy of the system can be calculated as follows:
    $PE={\frac {N}{2}}4\pi \rho \int _{0}^{\infty }r^{2}u(r)g(r)dr,$
where N is the number of particles in the system, $\rho$ is the number density, $u(r)$ is the pair potential.
The pressure of the system can also be calculated by relating the 2nd virial coefficient to $g(r)$. The pressure can be calculated as follows:
    $P=\rho kT-{\frac {2}{3}}\pi \rho ^{2}\int _{0}^{\infty }dr{\frac {du(r)}{dr}}r^{3}g(r)$.
Note that the results of potential energy and pressure will not be as accurate as directly calculating these properties because of the averaging involved with the calculation of $g(r)$.

## Approximations

For dilute systems (e.g. gases), the correlations in the positions of the particles that $g(r)$ accounts for are only due to the potential $u(r)$ engendered by the reference particle, neglecting indirect effects. In the first approximation, it is thus simply given by the Boltzmann distribution law:
| $g(r)=\exp \left[-{\frac {u(r)}{kT}}\right]$. | (11) |
If $u(r)$ were zero for all $r$ – i.e., if the particles did not exert any influence on each other, then $g(r)=1$ for all $\mathbf {r}$ and the mean local density would be equal to the mean density $\rho$: the presence of a particle at O would not influence the particle distribution around it and the gas would be ideal. For distances $r$ such that $u(r)$ is significant, the mean local density will differ from the mean density $\rho$, depending on the sign of $u(r)$ (higher for negative interaction energy and lower for positive $u(r)$).
As the density of the gas increases, the low-density limit becomes less and less accurate since a particle situated in $\mathbf {r}$ experiences not only the interaction with the particle at O but also with the other neighbours, themselves influenced by the reference particle. This mediated interaction increases with the density, since there are more neighbours to interact with: it makes physical sense to write a density expansion of $g(r)$, which resembles the virial equation:
| $g(r)=\exp \left[-{\frac {u(r)}{kT}}\right]y(r)\quad \mathrm {with} \quad y(r)=1+\sum _{n=1}^{\infty }\rho ^{n}y_{n}(r)$. | (12) |
This similarity is not accidental; indeed, substituting (12) in the relations above for the thermodynamic parameters (Equations 7, 9 and 10) yields the corresponding virial expansions. The auxiliary function $y(r)$ is known as the cavity distribution function.$^{:Table4.1}$ It has been shown that for classical fluids at a fixed density and a fixed positive temperature, the effective pair potential that generates a given $g(r)$ under equilibrium is unique up to an additive constant, if it exists.
In recent years, some attention has been given to develop pair correlation functions for spatially-discrete data such as lattices or networks.

## Experimental

One can determine $g(r)$ indirectly (via its relation with the structure factor $S(q)$) using neutron scattering or x-ray scattering data. The technique can be used at very short length scales (down to the atomic level) but involves significant space and time averaging (over the sample size and the acquisition time, respectively). In this way, the radial distribution function has been determined for a wide variety of systems, ranging from liquid metals to charged colloids. Going from the experimental $S(q)$ to $g(r)$ is not straightforward and the analysis can be quite involved.
It is also possible to calculate $g(r)$ directly by extracting particle positions from traditional or confocal microscopy. This technique is limited to particles large enough for optical detection (in the micrometer range), but it has the advantage of being time-resolved so that, aside from the statical information, it also gives access to dynamical parameters (e.g. diffusion constants) and also space-resolved (to the level of the individual particle), allowing it to reveal the morphology and dynamics of local structures in colloidal crystals, glasses, gels, and hydrodynamic interactions.
Direct visualization of a full (distance-dependent and angle-dependent) pair correlation function was achieved by a scanning tunneling microscopy in the case of 2D molecular gases.

## Higher-order correlation functions

It has been noted that radial distribution functions alone are insufficient to characterize structural information. Distinct point processes may possess identical or practically indistinguishable radial distribution functions, known as the degeneracy problem. In such cases, higher order correlation functions are needed to further describe the structure.
Higher-order distribution functions $\textstyle g^{(k)}$ with $\textstyle k>2$ were less studied, since they are generally less important for the thermodynamics of the system; at the same time, they are not accessible by conventional scattering techniques. They can however be measured by coherent X-ray scattering and are interesting insofar as they can reveal local symmetries in disordered systems.