# Testing discrete data for periodicity

I have some data which looks roughly periodic - is there a nice way to measure this?

This is an example I'm working on and I'd like a metric that I will be able to just threshold to give a decision of yes or no. I was thinking maybe looking into the Fourier domain or looking at correlation. Many thanks.

[NB - I've cross-posted - I've also asked on the stats stack exchange but I think it may be more appropriate here]

well, there is always autocorrelation $$R_x(\tau)=\sum x[n] x[n+\tau]$$ or AMDF $$Q_x(\tau) = \sum |x[n] - x[n+\tau]|$$ or ASDF $$Q_x(\tau) = \sum (x[n] - x[n+\tau])^2$$ with the latter there is the relationship between autocorrelation and ASDF $$R_x(\tau)=R_x(0) - \frac12 Q_x(\tau)$$. a measure of periodicity might be $\frac{R_x(P)}{R_x(0)}$ where $R_x(P)>R_x(\tau)$ for all $\tau\ne 0$. sometimes we call "$P$" the "period". if $\frac{R_x(P)}{R_x(0)} \approx 1$ we say it's pretty periodic.