aewallin / allantools

Allan deviation and related time & frequency statistics library in Python
GNU Lesser General Public License v3.0
226 stars 77 forks source link

How does this apply to general signals? #121

Closed shaperilio closed 4 years ago

shaperilio commented 4 years ago

The example from Analog Devices here gives the following value for the deviation with tau = 1 second (after you fix the slight mistakes in their spreadsheet):

0.004 878 48

Following the description here, I implemented my own version. This description is very simple: "the Allan Deviation for tau = 1 second is the standard deviation of the averages of the signal every 1 second" (there are 30 such periods in this dataset). I compute:

0.004 954 74

Which is "close".

If I call (taus, adev, _, ns) = allantools.adev(data, rate_Hz, taus=1) with rate_Hz = 10, I get:

0.031 938 69

Which is "not even close".

This equation from Wikipedia is perplexing me:

image

Your implementaiton of adev seems to be the right side, with x; the spreadsheet uses the version with y_bar, where, according to them, y_bar = mean x for each subperiod of length tau, which is most definitely not algebraically equivalent to what you've implemented. The "verbal" version I implemented is not algebraically equivalent to either.

I understand, as usual, that different people call things by different names (the spreadsheet refers to "variance" when they mean "deviation"), but what gives? What is the general application of this library to a sampled signal?

aewallin commented 4 years ago

When ADEV is used for time/frequency data the x-formula and y-formula are equivalent, because fractional frequency y is the time derivative of phase x.

When ADEV is (mis)used for other raw data input like voltage (or like above, acceleration?), you most probably want to treat it like (fractional) frequency data and use the y-formula. this is done in allantools with the data_type='freq' argument.

The AD-website link talks about 30s averages - allantools does the averaging for you. feed the raw data (e.g. sampled at 10S/s), and if you want ADEV at both tau=1s and tau=30s, with rate=10(Hz), then call with taus=[1,30]

shaperilio commented 4 years ago

Thanks for the clarification!