Signal averaging

From HandWiki
Revision as of 06:18, 26 October 2021 by imported>Steve Marsio (correction)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Signal processing technique

Signal averaging is a signal processing technique applied in the time domain, intended to increase the strength of a signal relative to noise that is obscuring it. By averaging a set of replicate measurements, the signal-to-noise ratio (SNR) will be increased, ideally in proportion to the square root of the number of measurements.

Deriving the SNR for averaged signals

Assumed that

  • Signal [math]\displaystyle{ s(t) }[/math] is uncorrelated to noise, and noise [math]\displaystyle{ z(t) }[/math] is uncorrelated : [math]\displaystyle{ E[z(t)z(t-\tau)] = 0 = E[z(t)s(t-\tau)]\forall t,\tau }[/math].
  • Signal power [math]\displaystyle{ P_{signal}=E[s^2] }[/math] is constant in the replicate measurements.
  • Noise is random, with a mean of zero and constant variance in the replicate measurements: [math]\displaystyle{ E[z] = 0 = \mu }[/math] and [math]\displaystyle{ 0 \lt E[\left(z-\mu\right)^2] = E[z^2] = P_{noise} = \sigma^2 }[/math].
  • We (canonically) define Signal-to-Noise ratio as [math]\displaystyle{ SNR = \frac{P_{signal}}{P_{noise}} = \frac{E[s^2]}{\sigma^2} }[/math].

Noise power for sampled signals

Assuming we sample the noise, we get a per-sample variance of

[math]\displaystyle{ \mathrm{Var}(z)=E[z^2] = \sigma^2 }[/math].

Averaging a random variable leads to the following variance:

[math]\displaystyle{ \mathrm{Var}\left(\frac 1n \sum_{i=1}^n z_i\right) = \frac 1{n^2} \mathrm{Var}\left(\sum_{i=1}^n z_i\right)= \frac 1{n^2} \sum_{i=1}^n\mathrm{Var}\left( z_i\right) }[/math].

Since noise variance is constant [math]\displaystyle{ \sigma^2 }[/math]:

[math]\displaystyle{ \mathrm{Var}(N_\text{avg}) = \mathrm{Var}\left(\frac 1n \sum_{i=1}^n z_i\right) = \frac 1{n^2} n \sigma^2 = \frac 1n \sigma^2 }[/math],

demonstrating that averaging [math]\displaystyle{ n }[/math] realizations of the same, uncorrelated noise reduces noise power by a factor of [math]\displaystyle{ n }[/math], and reduces noise level by a factor of [math]\displaystyle{ \sqrt{n} }[/math].

Signal power for sampled signals

Considering [math]\displaystyle{ n }[/math] vectors [math]\displaystyle{ V_i,\,i \in\{1,\ldots,n\} }[/math] of signal samples of length [math]\displaystyle{ T }[/math]:

[math]\displaystyle{ V_i = \left[s_{i,1}, \ldots, s_{i,T}\right],\quad s_{i,k} \in \mathbb K^T }[/math],

the power [math]\displaystyle{ P_i }[/math] of such a vector simply is

[math]\displaystyle{ P_i = \sum_{k=1}^T {s_{i,k}^2} = \left| V_i \right|^2 }[/math].

Again, averaging the [math]\displaystyle{ n }[/math] vectors [math]\displaystyle{ V_{i},\,i=1,\ldots,n }[/math], yields the following averaged vector

[math]\displaystyle{ V_\text{avg} = \frac 1n \sum_{k=1}^T\sum_{i=1}^n s_{i,k}= \frac 1n \sum_{i=1}^n \sum_{k=1}^T s_{i,k} }[/math].

In the case where [math]\displaystyle{ V_n \equiv V_m \forall m,n \in \{ 1,\ldots, n\} }[/math], we see that [math]\displaystyle{ V_\text{avg} }[/math] reaches a maximum of

[math]\displaystyle{ V_\text{avg, identical signals} = P_i }[/math].

In this case, the ratio of signal to noise also reaches a maximum,

[math]\displaystyle{ \text{SNR}_\text{avg, identical signals} = \frac{V_\text{avg, identical signals}}{N_\text{avg}} = n \text{SNR} }[/math].

This is the oversampling case, where the observed signal is correlated (because oversampling implies that the signal observations are strongly correlated).

Time-locked signals

Averaging is applied to enhance a time-locked signal component in noisy measurements; time-locking implies that the signal is observation-periodic, so we end up in the maximum case above.

Averaging odd and even trials

A specific way of obtaining replicates is to average all the odd and even trials in separate buffers. This has the advantage of allowing for comparison of even and odd results from interleaved trials. An average of odd and even averages generates the completed averaged result, while the difference between the odd and even averages, divided by two, constitutes an estimate of the noise.

Algorithmic implementation

The following is a MATLAB simulation of the averaging process:

N=1000;   % signal length
even=zeros(N,1);  % even buffer
odd=even;         % odd buffer
actual_noise=even;% keep track of noise level
x=sin(linspace(0,4*pi,N))'; % tracked signal
for ii=1:256 % number of replicates
    n = randn(N,1); % random noise
    actual_noise = actual_noise+n;
    
    if (mod(ii,2))
        even = even+n+x;
    else
        odd=odd+n+x;
    end
end

even_avg = even/(ii/2); % even buffer average 
odd_avg = odd/(ii/2);   % odd buffer average
act_avg = actual_noise/ii; % actual noise level

db(rms(act_avg))
db(rms((even_avg-odd_avg)/2))
plot((odd_avg+even_avg)); 
hold on; 
plot((even_avg-odd_avg)/2)

The averaging process above, and in general, results in an estimate of the signal. When compared with the raw trace, the averaged noise component is reduced with every averaged trial. When averaging real signals, the underlying component may not always be as clear, resulting in repeated averages in a search for consistent components in two or three replicates. It is unlikely that two or more consistent results will be produced by chance alone.

Correlated noise

Signal averaging typically relies heavily on the assumption that the noise component of a signal is random, having zero mean, and being unrelated to the signal. However, there are instances in which the noise is not uncorrelated. A common example of correlated noise is quantization noise (e.g. the noise created when converting from an analog to a digital signal).

References