|
|
SNR calculation via FFT-based crosscorrelationSummary
CrosscorrelationThe method uses the normalized crosscorrelation coefficientFor example:
Samples and powerSamples could represent a physical quantity such as electrical voltage or current. Power is proportional to the square of the amplitude.The same applies, even if the samples do not represent an electric signal. For example, Signal-to-noise ratioThe common partThe signal-to-noise-ratio follows then as: AccuracyLower SNRs will require a longer signal for a given accuracy, since part of the noise is randomly correlated with the signal.Example code: Octave (tested) or Matlabdownload complete example (right-click, save as)The program includes the following steps:
% SNR detection via FFT / correlation
% Markus Nentwig 2007
% this program is in the public domain, provided without any warranty
close all; clear all;
N=65536;
% transmitted signal
a=randn(1, N);
x=[];
y=[];
for SNR_in_dB=-30:5:60
vRatio=power(10, -SNR_in_dB/20);
% construct time shifted, noisy "received" signal
b=circshift(a, [0, -1234])+vRatio*randn(1, N);
% scale to arbitrary amplitude...
a=a*12345;
b=b*23456;
% ... and normalize
ea=sum(a .* conj(a)) / N;
eb=sum(b .* conj(b)) / N;
a=a/sqrt(ea);
b=b/sqrt(eb);
% crosscorrelation
corr=ifft(fft(a) .* conj(fft(b)))/N;
% find peak (should be 1234+1)
maxBin=find(abs(corr)==abs(max(corr)));
c=abs(corr(maxBin));
% c is the ratio of "voltage" in a explained by b and vice versa
% c^2 is the ratio of power => signal
% 1-c^2 is the remaining part unexplained by signal => noise
% note, low SNRs require a longer signal, because part of the noise will randomly correlate with the reference signal.
SNR_out=c^2/(1-c^2);
SNR_out_dB=10*log10(SNR_out);
x=[x, SNR_in_dB];
y=[y, SNR_out_dB];
end
plot(x, y, '+-');
xlabel('SNR in/dB'); ylabel('SNR out/dB');
Result
TimingA delay mismatch betweenThe result isn't particularly sensitive, as long as the signal is narrowband compared to the sampling rate (because the center peak of the signal's autocorrelation function is wide). For signals using a large percentage of the bandwidth, for example oversampling by 2, even small timing errors may have a significant impact on SNR. In such a case, it is possible to raise the sampling rate of signal and reference through FFT-interpolation, giving better timing resolution.
Limiting the bandwidthA meaningful SNR definition requires a filter.Noise that is filtered out by the (ideal) receiver should be excluded.
Crosscorrelation-based SNR without FFTThe above example uses FFT to calculate the crosscorrelation. As an additional benefit it finds the optimum timing to align signal and reference, with a resolution of one sample.But frequently, In this case, the crosscorrelation can be calculated directly on the normalized sample streams. The conjugate is only required, when samples are complex-valued. download complete example
Further readingEVM, SNR and the “waveform quality factor”© Markus Nentwig 2007-2008 The content of this page is provided without any warranty and may not be reproduced without permission. Comments? Questions?Please send me a mail! mnentwig@elisanet.fi |