Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a 1-dimensional array with some integers, which are periodically increasing. Something like this (1 period here):

{1, 2, 1, 1, 3, 6, 8, 5, 5, 3, 1, 2, 2, 1, 1, 2, 1, 3, 5, 7, 7, 6, 3, 2, 1}

There can be any number of periods, usually 2 in my arrays. I need to calculate it, and I want to believe, that Wolfram Mathematica already has function I need, but I can't find it.

enter image description here

P.S.: wanted tag feature-detection, but it doesn't exist.

UPD: I found, that have to deal with much more big 'noise', that I thought before... There are fake peaks (but only on near 20% of arrays), which look almost like the peaks I'm interested in. But fortunately I almost always have 3 not-fake peaks in each array, and there are near 100-150 arrays total, that all have the same period +/-2%, which I need to find.

enter image description here

share|cite|improve this question
Have you tried autocorrelation? Something like $$\theta(M)=\sum_{n=1}^{L-M}a_na_{n+M},$$ where $(a_n)$ is your sequence, and $L$ is its length. The parameter $M$ is the 'candidate' period. What should happen is that the function $\theta(M)$ has a maximum, when $M$ is (near) the period, because then it collects terms where $a_n$ and $a_{n+M}$ are both large. This approach has the disadvantage that the total number of terms drops, when $M$ grows, so if $L$ is not much larger than $M$, the 'noise' may conceal the period. Another possibility would be a discrete Fourier transform. Try those! – Jyrki Lahtonen Nov 9 '11 at 4:56
@JyrkiLahtonen, if I don't find magic Mathematica function for it, this approach will be the one I'll implement. – Nakilon Nov 9 '11 at 5:26
Here's a tutorial on correlations in Mathematica. It's late here, so I don't have time to write up a complete answer. – rcollyer Nov 9 '11 at 5:33
Have you tried taking the discrete Fourier transform of your data? With $L$ data points, the period $P$ of the signal should show up as peaks in the spectrum at frequencies $L/P$ and $L-L/P$. See for example tutorial/FourierTransforms in the documentation centrum of Mathematica for more information. – Heike Nov 9 '11 at 11:39
@Heike why not post that as an answer so I can vote for it? – Mr.Wizard Nov 14 '11 at 6:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.