# Good test for periodicity between signals

I have two timeseries signals. They look like this:

Each signal started out from the same array, but each received different preprocessing treatments. Ultimately, each signal represents the breathing rate of a subject. Each peak constitutes the peak of an inhale, so the number of peaks/time yields the respiratory rate. I want to determine which preprocessing treatments yield a more periodic signal so that I can conduct the most optimal peak detection.

As you can see, both signals are noisy, but it looks like the orange timeseries has more consistent periodicity, making it more suitable for my task. What is an optimal test to determine how periodic each signal is so that I can determine the signal without having to look at them?

Ideally, a solution implemented in python or c++ would be great, but not necessary.

### Edit

Here is a way to compute average frequency per signal.

Am I correct to assume the higher value is more periodic, or is that too simplistic?

### Edit 2

More "periodic" probably isn't the right term. This is what I mean:

The first plot has less noise, so it is cleaner/easier to determine the periods between peaks. Again, I am ultimately trying to solve a peak detection problem.

• What do you mean by “more periodic”? Commented Jan 29, 2021 at 12:53
• I am somewhat new to signals, so apologies if my language is not ideal. See my new edits for an explanation of what I mean. Commented Jan 29, 2021 at 13:14
• Oh I see. Signal to noise ratio (SNR) is probably the term you want Commented Jan 29, 2021 at 15:04
• The question is not very well stated. It is unclear, what your final goal is. Is it to determine the main frequency of the signal, ie the breathing cycle? Also, the measurements look very strange. How was it measured? Why are the two curves so different, if they originate from the same raw data? What are the units of the x and y axes? Is it at all legit to assume that there is ONE breathing frequency over such a long time? Also, you compute the mean value of the abs-power spectrum, which is an arbitrary number if you don't normalize your spectra, and it is unclear whether this is what you need
– M529
Commented Jan 29, 2021 at 18:00

• Not necessarily. As someone mentioned, you need a precise definition of periodicity. To give you an example: consider $f(t)=sin(2t)$ and $g(t)=10sin(2t)$, then if you take the FFT, you're going to get that both signal have a strong peak at the frequency 2, but $g$ has a higher peak because its magnitude is bigger; is it more periodic? it depends on your definition of periodicity. You can probably define the notion of periodicity in some way that works for your problem, but you need to be careful about contradictions. Hope that makes sense. Commented Jan 29, 2021 at 23:49