0
$\begingroup$

I have a magnetometer, a LIS3MDL to be precise, and I am taking readings from it every second. As expected there is variation in the readings. For example, if I take five readings I get:

1164, 1190, 1270, 1186, 1260

Now maybe five samples is enough to average over, maybe it is not. How do I know this? Is there a way to use the FFT of a large number of samples to work out the optimum number of samples to take?

$\endgroup$
1
  • 1
    $\begingroup$ What do you mean by "is enough"? You can perform an average on even just 2 samples. So, rather than the FFT, you might want to see how big the standard deviation is for various lengths of sample blocks. As you increase the size of the block, if the standard deviation does not increase much, then I think you have a good block size to do nearly any statistical measurement. I would take a look at this section of Wikipedia to learn of an important subtlety. $\endgroup$ Jun 7 at 16:12

2 Answers 2

1
$\begingroup$

When you take many samples and calculate an FFT, you likely find that noise is flat in the higher portion of the spectrum and for lower frequencies eventually noise will rise proportional to √f or even faster.

The important bit is that averaging longer than the inverse corner frequency does not improve the accuracy of the reading any more.

Therefore, one sweetspot for the optimum number of samples to average is to accumulate samples for a time equal to the inverse corner frequency, which will provide maximum precision.

If you need reading faster, you can use fewer readings at the expense of slightly higher noise.

$\endgroup$
1
$\begingroup$

The optimum number of samples to average over for any series of data which may become non-stationary over longer time intervals is readily determined by using the "Allan Deviation" (ADEV) and "Allan Variance" (AVAR). ADEV and AVAR are typically used in the evaluation of oscillator stability since that is an inherently non-stationary process, but it can also be used to evaluate the optimum FFT duration as I have described in further detail here specific to using this with an FFT. A plot of the Allan Deviation shows the standard deviation of the difference $\tau$ between two blocks of samples averaged over $\tau$ seconds and will be minimum at the length of $\tau$ corresponding to the optimum averaging interval. Over this duration of time the waveform statistics are sufficiently stationary such that averaging will minimize the estimate of the mean.

I go over this in more detail at the following posts:

Is Allan variance still relevant?

How to interpret Allan Deviation plot for gyroscope?

Allan Variance vs Autocorrelation - Advantages

How to interpret ADEV plot?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.