i have two audacity files, one includes noise data and the other includes signal data. how do I calculate noise to signal ratio between the data in these two files? thank you

  • 1
    $\begingroup$ you probably meant, signal to noise ratio instead... $\endgroup$ – Fat32 Jul 20 '17 at 12:10
  • $\begingroup$ good point Fat32. $\endgroup$ – S Fateri Aug 22 '17 at 12:26

Signal to noise ratio (SNR) is a local relation between a signal $x[n]$ and and noise $w[n]$ and is defined as: $$\text{SNR} = \frac{\sigma_x^2}{\sigma_w^2}$$ where $\sigma_x^2$ and $\sigma_w^2$ denote the powers of the discrete-time signal $x[n]$ and noise $w[n]$ respectively.

Therefore if the signals involved are non-stationary of any sort, then the computed SNR will change from point to point as the signals change their character. One immediate application of this concept is in the audio industry known as those Dolby noise reduction systems, which roughly relies on the time varying SNR computation and SNR based gain control in the recording and playback systems to minimize hearable audio noise in the music.

For this reason, as a single parameter, SNR only makes sense iff the signals involved are stationary or at least WSS. Otherwise an average SNR can provide little help.

Then the theoretical computations of $\sigma_w^2$ and $\sigma_x^2$ depend on the signal models being employed. Since noise is by definition a random signal and we restrict it to a zero mean WSS noise process, then its theoretical power is computed in terms of an expectation; $$\sigma_w^2 = \text{E}\{ w(n)^2 \}$$ for a zero mean random process, this expectation is equivalent to the variance of the noise process; i.e., $$ E\{w[n]^2\} = E\{ ( w[n]-E\{w[n]\})^2 \} = \text{Var}(w[n]) = \sigma_w^2 $$

Note that in theoretical computation of noise power, it's more useful to consult to the auto-correlation sequence (ACS) of the WSS noise process as: $$E\{w[n]^2\} = r_{ww}[0]$$ where ACF of a WSS process is defined as $r_{ww}[m] = E\{w[n]w[n+m]^{*}\}$ and which has a practical estimation based on ergodicity assumption below.

The signal $x[n]$ will have a deterministic definition and its average power can be computed as: $$\sigma_x^2 = \frac{1}{N} \sum_{n=0}^{N-1} |x[n]|^2 $$ by replacing $x[n]$ with the formula that defines it and by explicitly carrying out the summation along the signal length $N$ for a closed form expression of the signal power. Note that eventhough a variance symbol is used to represent the average power of $x[n]$, it's a deterministic signal (at least in the theoretical computation)

In a practical setting, variance of the noise is computed by estimating it from a time-average of the given realization $w[n]$ in the time domain, relying on the assumption of ergodicity of the white noise process. Hence ; $$\sigma_w^2 = E\{w[n]^2\} = r_{ww}[0] \longleftrightarrow \frac{1}{N} \sum_{n=0}^{N-1} w[n]w[n+0]^{*} = \frac{1}{N} \sum_{n=0}^{N-1} |w[n]|^2 $$

Similarly in a practical setting the power for the deterministic signal is computed by the average sum of the sample squares: $$\sigma_x^2 = \frac{1}{N} \sum_{n=0}^{N-1} |x[n]|^2$$ where $N$ is the extent of the segment along which an SNR is computed.

Note that eventhough the theoretical computation of the SNR (theoretical computations of the signal and noise powers) relied on different procedures used for the signal power and noise power, the practical computation of the SNR relies on exactly the same procedure for both powers.

Finally, in most cases SNR is described in a logarithmic scale with dB units; $$\text{SNR}_{dB} = 10 \log_{10}(SNR) = 10 \log_{10}(\frac{\sigma_x^2}{\sigma_w^2})$$

| improve this answer | |

Compute the energy of the noise ($E_n$), the energy of the signal ($E_s$). Classically, the signal-to-noise ratio, computed in decibels, is often defined as:

$$10\log \frac{E_s}{E_n} $$

The noise-to-signal ratio could just be the opposite.

| improve this answer | |

There are different ways to calculate SNR of a signal response. It depends on your application that defines the fairest way to measure SNR.

  1. dB ratio between the maximum amplitude of a noise against maximum amplitude of the main signal of interest: $$ 20*log_{10} (max(Signal)/max(NoiseMax)) $$ where Max is the amixmum peak detector operation.
  2. dB ratio between the average or root mean square of a range of noise amplitude (in time/space) against maximum amplitude of the main signal of interest: $$ 20*log_{10} (SignalMax/RMS(NoiseRange)) $$ where RMS is root mean square operation.
  3. dB ratio between the standard devation of a range of noise amplitude (in time/space) against maximum amplitude of the main signal of interest: $$ 20*log_{10} (SignalMax/SD(NoiseRange)) $$ where SD is standard deviation operation.

In applications where signals are fully mixed with coherent noise, it is recommended to use either #2 or #3. In applications where the main signal of interest and noise can be seen separately, it is recommended to use #1.

There are other ways to measure SNR and again they are appication dependent.

| improve this answer | |
  • $\begingroup$ What's the practical application of your first definition of SNR (amplitude based)? I cant think of a way this SNR is useful for an application. Thanks. $\endgroup$ – user13107 May 16 '18 at 1:11

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.