In probability theory and statistics, the covariance function describes how much two random variables change together (their covariance) with varying spatial or temporal separation. For a random field or stochastic process Z(x) on a domain D, a covariance function C(x, y) gives the covariance of the values of the random field at the two locations x and y:
C ( x , y ) := cov ( Z ( x ) , Z ( y ) ) = E [ ( Z ( x ) − E [ Z ( x ) ] ) ( Z ( y ) − E [ Z ( y ) ] ) ] . {\displaystyle C(x,y):=\operatorname {cov} (Z(x),Z(y))=\mathbb {E} {\Big [}{\big (}Z(x)-\mathbb {E} [Z(x)]{\big )}{\big (}Z(y)-\mathbb {E} [Z(y)]{\big )}{\Big ]}.\,}
The same C(x, y) is called the autocovariance function in two instances: in time series (to denote exactly the same concept except that x and y refer to locations in time rather than in space), and in multivariate random fields (to refer to the covariance of a variable with itself, as opposed to the cross covariance between two different variables at different locations, Cov(Z(x1), Y(x2))).