To do a correlation or an autocorrelation of a magnitude or a complex number is straightforward. But what if you want to calculate the correlation of a phase? The problem being that, if your phases run from 0 to 2$\pi$ for example, $2\pi+\epsilon$ is very close to $2\pi-\epsilon$, but will not look that way at all if I just simply calculate $\int \phi(t) \phi(t+\tau) dt$. What is a correct way to handle the numerical discontinuity? Thanks.