3
$\begingroup$

I created short audio files with a sine wave (tone) having a set frequency, and added varying white noise to it generated by a random number generator. I wanted to code and test the simple algorithm described in IEEE-STD-1057 & 1241 to calculate the frequency in the time domain by measuring the times the amplitudes flip sign. This works well when white noise has been added, but is less accurate when white noise is absent. What's the reason why the added white noise improves accuracy?

Just guessing; might this have something to do with dithering? The difference between a smooth (analog) sine wave and the digitized one is a sawtooth with varying amplitudes - the quantization error. Dithering is the addition of noise in order to smooth the digitized recording. Digitizing an analog source causes quantization errors, and dithering compensates for that in some way.

$\endgroup$
14
  • $\begingroup$ could you post your code for both algorithms? $\endgroup$
    – Ben
    Aug 19, 2021 at 13:41
  • 2
    $\begingroup$ Are you doing enough simulations per noise level? In a single test it could be. In many, it doesn't should be like that. $\endgroup$
    – Mark
    Aug 19, 2021 at 13:51
  • $\begingroup$ It's possible that without noise, your matrices become almost singular creating some numerical issues $\endgroup$
    – Ben
    Aug 19, 2021 at 13:59
  • $\begingroup$ The code is way too long to post here. I did many simulations to uncover the trends. No matrices involved in the calculations - just plain elementary arithmetic operations. $\endgroup$
    – Petoetje59
    Aug 19, 2021 at 14:03
  • $\begingroup$ Aren't they least-squares fit algorithms ? You usually have an overdetermined set of equations that you solve... If it smells like matrices, it's probably matrices. $\endgroup$
    – Ben
    Aug 19, 2021 at 14:16

2 Answers 2

1
$\begingroup$

An easy way to demonstrate how dithering improves accuracy in quantized systems (which includes the approach the OP used to estimate frequency) is to consider this example of a system that is quantized to integers with "truth" being some fraction in between such as $1.4$. With no noise added, our result would always be $1$. If we added enough noise with a uniform distribution of one quantization level, and could also oversample such that we can average the result- then we can see how in this case 60% of the samples will result in $1$ and 40% in $2$ resulting in $1.4$ on average.

$\endgroup$
0
$\begingroup$

Sounds like you have a zero crossing algorithm, and depending on the relationship between sine frequency and sampling frequency, I can easily see systematic errors when estimating frequency from zero crossing rate.

Adding noise would presumably act as a dither that introduce spurious perturbations about the true (desired) mean. If you estimate frequency from the mean of several zero crossing spacings, I can see that adding noise might benefit accuracy in some cases.

$\endgroup$
1
  • $\begingroup$ This is indeed a zero crossing algorithm. FYI, frequency of the sine wave was 1000Hz, sampling frequency 5512Hz, and the results were best when white noise was present, not so for the pure digitized sine wave which always resulted in 1004.0Hz, whilst the noisy ones always varied between 1000.6-1001.7Hz. $\endgroup$
    – Petoetje59
    Aug 21, 2021 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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