Period of a quasiperiodic digital signal I have a signal made of a perturbed square wave, sampled so that there are at least six samples per period, for a total of 15 to 50 periods. The sampling frequency and the signal frequency are unrelated.

The perturbations are of several types:


jitter in the period (say 10%),
variable amplitude of the squares (say from 1 to 3),
additional arbitrary signal with an amplitude below 1, often localized.


I am looking for a simple, fast but robust computational procedure to estimate the average period (preferaby without a DFT or autocorrelation).

Typical example:
You can locate each rising edge and use that as the start time of each new cycle. Then compute the time differences between their locations and then take reciprocal of the average (or median, for more robustness against outliers) of these time differences to estimate frequency.

Locating the rising edges can be achieved by checking if the difference in consecutive data points exceeds a predetermined threshold. This threshold can be set adaptively from data. For instance, if you make a scatter plot of all your data samples it should look bimodal: the higher values correspond to the peaks of the square wave and the lower values to the valleys.