In statistical mechanics, the correlation function is a measure of the order in a system, as characterized by a mathematical correlation function. Correlation functions describe how microscopic variables, such as spin and density, at different positions are related. More specifically, correlation functions quantify how microscopic variables co-vary with one another on average across space and time. A classic example of such spatial correlations is in ferro- and antiferromagnetic materials, where the spins prefer to align parallel and antiparallel with their nearest neighbors, respectively. The spatial correlation between spins in such materials is shown in the figure to the right. Definitions The most common definition of a correlation function is the canonical ensemble (thermal) average of the scalar product of two random variables, and , at positions and and times and : Here the brackets, , indicate the above-mentioned thermal average. It is a matter of convention whether one subtracts the uncorrelated average product of and , from the correlated product, , with the convention differing among fields. The most common uses of correlation functions are when and describe the same variable, such as a spin-spin correlation function, or a particle position-position correlation function in an elemental liquid or a solid (often called a Radial distribution function or a pair correlation function). Correlation functions between the same random variable are autocorrelation functions. However, in statistical mechanics, not all correlation functions are autocorrelation functions. For example, in multicomponent condensed phases, the pair correlation function between different elements is often of interest. Such mixed-element pair correlation functions are an example of cross-correlation functions, as the random variables and represent the average variations in density as a function position for two distinct elements. Equilibrium equal-time (spatial) correlation functions Often, one is interested in solely the spatial influence of a given random variable, say the direction of a spin, on its local environment, without considering later times, . In this case, we neglect the time evolution of the system, so the above definition is re-written with . This defines the equal-time correlation function, . It is written as: Often, one omits the reference time, , and reference radius, , by assuming equilibrium (and thus time invariance of the ensemble) and averaging over all sample positions, yielding: where, again, the choice of whether to subtract the uncorrelated variables differs among fields. The Radial distribution function is an example of an equal-time correlation function where the uncorrelated