In optics[^1], we have a notion of [coherence](https://en.wikipedia.org/wiki/Degree_of_coherence#Degree_of_first-order_coherence), that's defined as a normalised correlation/cross-correlation/autocorrelation function: Simplifying notation from the linked Wiki page we can write the (un-normalised, first order) correlation function $$G^{(1)} = \left\langle XY\right\rangle,$$ where I'm using $\left\langle\ldots\right\rangle$ to represent the expectation value, which can then be normalised as $$g^{(1)} = \frac{\left\langle XY\right\rangle}{\sqrt{\left\langle X^2\rangle\langle Y^2\right\rangle}},$$ where $X$ and $Y$ are some matrices/operators/variables etc.
All seems well and good... Except the problem was already mentioned in the first sentence - the correlation between $X$ and $Y$ is [defined as](https://en.wikipedia.org/wiki/Correlation_and_dependence#Definition) $$g = \frac{\left\langle XY\right\rangle - \left\langle X\rangle\langle Y\right\rangle}{\sqrt{\left\langle X^2\right\\rangle - \left\langle X\right\rangle^2}\sqrt{\left\langle Y^2\right\\rangle - \left\langle Y\right\rangle^2}},$$ which is the normalised covariance $$G = \left\langle XY\right\rangle - \left\langle X\rangle\langle Y\right\rangle.$$
So, **how do we reconcile these similar yet different definitions?** More importantly, **how do you know which is the right one to use?** In order to tell how correlated two sets of data taken from the expectation of two different measurements of a signal are.
Initially, it seemed like the former might apply to operators and matrices in physics, while the latter applies to variables in statistics. However, there are a couple of issues with this - in taking the expectation of an operator, it instead becomes a continuous variable, which can be treated statistically. The second is that [I sometimes see the first definition of correlation $G^{(1)}$ used alongside the definition of covariance $G$](https://en.wikipedia.org/wiki/Cross-correlation#Cross-correlation_of_stochastic_processes), which if nothing else, is a *confusing* way of mixing different definitions.
[^1]: Yes, I know, starting a maths question with something about physics... Bear with me? Please?