---
title: Noise, averaging and lock-in detection
heading: Pulling small signals out of large noise
eyebrow: C11 · Lesson 16 · Noise, averaging and lock-in detection
xp: 40
---

::: hook
A strain gauge's output is a few microvolts; the amplifier in front of it adds noise a hundred times larger. The signal is still recoverable, because noise and signal behave differently when you repeat or filter them. A repeating signal adds up coherently over many sweeps while random noise only grows as the square root, and a signal at a known frequency can be picked out with a filter far narrower than any analog circuit could make: that's what a **lock-in amplifier** does, and it routinely measures signals buried a thousand times below the noise.
:::

::: play
- Each draw is one reading of a 1 mV signal buried in noise with a standard deviation of s mV. The trace is the running average of the readings so far; the dashed line is the true 1 mV.
- With s = 10 mV, a single reading is useless, but after a few hundred the average closes in. Its error shrinks as $s/\sqrt N$.
- Raise the noise: the average still converges, just more slowly. Ten times the noise needs a hundred times the readings.
:::
:::

```sim plot
view: random
x: v = -40..40 mV
slider: s = 1..30 step 1 = 10 mV
sample: 1 + s*randn(1) | mean: M | sd: S
trials: 2000
bins: 40
trace: 2000 | running
marker: trace = 1 | label: true value
readout: average of all readings = M mV
readout: expected error after 2000, mV = s/sqrt(2000) | digits: 3
```

::: predict
## A scope averages 100 sweeps of a repeating signal. By how much does the random noise on the display fall?

- [ ] 100 times (40 dB)
- [x] 10 times (20 dB)
- [ ] 2 times (6 dB)
- [ ] Not at all

::: reveal
10 times, 20 dB. The signal is identical in every sweep, so it averages to itself; the noise is independent from sweep to sweep, so its average shrinks as $1/\sqrt N$. In power terms the SNR improves by $10\log_{10}N$ dB.
:::
:::

::: nameit
## Averaging

Averaging N independent records of a repeating signal leaves the signal and divides the noise's RMS by $\sqrt N$:

$$\text{SNR gain} = 10\log_{10}N \text{ dB}$$

It needs a stable trigger, so every record lines up, and it can't remove noise that's synchronized with the signal.

## Filtering

Random noise's power is spread over frequency, so a narrower bandwidth passes less of it: noise RMS goes as $\sqrt{B}$. A single-pole RC filter has an **equivalent noise bandwidth** of

$$\text{ENBW} = \frac{1}{4RC}$$

(π/2 times its −3 dB bandwidth). With a noise density $e_n$ in V/√Hz, the noise is $e_n\sqrt{\text{ENBW}}$.

## Lock-in detection

A lock-in amplifier multiplies the input by a reference at the signal's frequency (as in synchronous demodulation, C9.48) and low-passes the product with time constant τ. Only input near the reference frequency survives, through a bandwidth of about $1/(4\tau)$, which can be a fraction of a hertz, centered wherever the reference is. To use it, **modulate** the quantity being measured (chop a light beam, drive a sensor with AC), which also moves the measurement away from low-frequency $1/f$ noise and drift.

## The noise you start with

A resistor's thermal (Johnson) noise is $\sqrt{4kTRB}$ (A11): 407 nV for 1 kΩ over 10 kHz at room temperature. That sets the floor no amount of amplification can beat, only narrower bandwidth.
:::

::: example
## A lock-in uses a 0.1 s time constant on a signal with 10 nV/√Hz of noise density. What noise does it see?

::: solution
1. **Noise bandwidth.**
   $$\begin{aligned} \text{ENBW} &= \frac{1}{4 \times 0.1\ \text{s}} \\ &= 2.5\ \text{Hz} \end{aligned}$$
2. **Noise.**
   $$\begin{aligned} v_n &= 10\sqrt{2.5}\ \text{nV} \\ &= 15.8\ \text{nV} \end{aligned}$$
3. **Compared with a scope.** A 100 nV signal, invisible on a scope with 100 kHz of bandwidth (3.2 µV of noise), reads with an SNR of 6.

**Answer:** it sees 15.8 nV of noise.
:::
:::

::: example
## How many sweeps must be averaged to improve the SNR by 30 dB?

::: solution
1. **Sweeps needed.** Averaging N sweeps gains $10\log_{10}N$ dB, so
   $$\begin{aligned} N &= 10^{30/10} \\ &= 1000 \end{aligned}$$
2. **Further gains.** Each further 10 dB costs ten times as many.

**Answer:** 1000 sweeps.
:::
:::

::: example
## A repetitive signal is 20 dB below the noise in a single sweep. How many sweeps must be averaged to see it with 20 dB of SNR?

::: solution
1. **Improvement needed.** From −20 dB to +20 dB, the SNR must rise by 40 dB.
2. **Sweeps needed.** Averaging N sweeps gains $10\log_{10}N$ dB, so
   $$\begin{aligned} N &= 10^{40/10} \\ &= 10^4 \end{aligned}$$
3. **How long it takes.** At one sweep a millisecond that's 10 s, fine; at one a second, nearly three hours, and drift would likely spoil it first.
4. **Another tool.** Narrowing the bandwidth (a lock-in) is often the better tool.

**Answer:** $10^4$ sweeps.
:::
:::

::: check
given: N = 4 | 64 | 1000 | 10000
answer: 10*log(N)
unit: dB
tolerance: 0.5%

## A repeating signal is averaged over {N} records. By how many dB does its SNR improve?

::: right
Right. $10\log_{10}N$ = {answer} dB.
:::

::: misses
- [20*log(N)] Noise RMS falls as $\sqrt N$: that's 10 log N in dB.
- [any] Not yet. $10\log_{10}N$.
:::
:::

::: check
given: X = 10 | 20 | 26 | 40
answer: 10^(X/10)
tolerance: 0.5%

## How many records must be averaged to improve the SNR by {X} dB?

::: right
Right. $10^{X/10}$ = {answer}.
:::

::: misses
- [10^(X/20)] SNR in dB is a power ratio: $10^{X/10}$.
- [any] Not yet. Invert $10\log_{10}N$.
:::
:::

::: check
given: tau = 0.01 | 0.3 | 3
answer: 1/(4*tau)
unit: Hz
tolerance: 0.5%

## A lock-in's single-pole filter has a time constant of {tau} s. What is its equivalent noise bandwidth?

::: right
Right. $1/(4\tau)$ = {answer} Hz.
:::

::: misses
- [1/(2*pi*tau)] That's the −3 dB bandwidth; the noise bandwidth is π/2 times larger, 1/(4τ).
- [any] Not yet. $1/(4RC)$.
:::
:::

::: check
given: en = 4 | 10 | 50; B = 10 | 100 | 10000
answer: en*sqrt(B)
unit: nV
tolerance: 0.5%

## An amplifier has {en} nV/√Hz of noise. How much noise appears in a {B} Hz bandwidth?

::: right
Right. $e_n\sqrt B$ = {answer} nV.
:::

::: misses
- [en*B] Noise voltage grows as the square root of bandwidth.
- [any] Not yet. $e_n\sqrt{B}$.
:::
:::

::: check
given: R = 100 | 1000 | 100000; B = 1000 | 20000
answer: sqrt(4*1.380649e-23*300*R*B)*1e9
unit: nV
tolerance: 0.5%

## What is the thermal noise of a {R} Ω resistor at 300 K over {B} Hz?

::: right
Right. $\sqrt{4kTRB}$ = {answer} nV.
:::

::: misses
- [any] Not yet. $\sqrt{4kTRB}$.
:::
:::

::: check
given: s = 5 | 20 | 50; N = 25 | 400
answer: s/sqrt(N)
unit: mV
tolerance: 0.5%

## Readings with {s} mV of noise are averaged {N} times. What noise is left on the average?

::: right
Right. $s/\sqrt N$ = {answer} mV.
:::

::: misses
- [s/N] It falls as $\sqrt N$.
- [any] Not yet. $s/\sqrt N$.
:::
:::

::: check
kind: choice

## A sensor's output drifts slowly and has strong 1/f noise below 10 Hz. How can a lock-in help measure a slowly changing quantity?

- [ ] Use a very long time constant directly on the DC signal
- [x] Excite the sensor with AC at, say, 1 kHz, and lock in to that frequency
- [ ] Average the DC readings more
- [ ] It can't; lock-ins only work on signals that are already AC

::: misses
- [1] At DC the 1/f noise and drift dominate, whatever the filter.
- [3] Averaging doesn't remove drift, which is correlated from reading to reading.
- [4] Modulating the measurement is exactly how DC quantities are measured with lock-ins.
:::
:::

::: check
kind: parts
given: g = 10 | 20 | 30 | 40

## Averaging must improve a repetitive signal's SNR by {g} dB.

::: part
answer: 10^(g/10)
tolerance: 0.5%

### How many sweeps?

::: misses
- [10^(g/20)] SNR here is in power: $10\log_{10}N$.
- [any] $N = 10^{g/10}$.
:::
:::

::: part
answer: 10^(g/20)
tolerance: 0.5%

### By what factor does the rms noise fall?

::: misses
- [any] $\sqrt N$.
:::
:::
:::

::: check
kind: parts
given: e = 5 | 20 | 100; t = 0.03 | 0.3 | 3

## A lock-in with a single-pole filter of time constant {t} s sees white noise of {e} nV/√Hz.

::: part
answer: 1/(4*t)
unit: Hz
tolerance: 0.5%

### What is its noise bandwidth?

::: misses
- [any] $1/4\tau$.
:::
:::

::: part
answer: e*sqrt(1/(4*t))
unit: nV
tolerance: 0.5%

### What rms noise does it pass?

::: misses
- [any] Density × √bandwidth.
:::
:::
:::

::: explain
## Why does averaging N sweeps improve the SNR by a factor of √N in amplitude, not N?

::: model
In each sweep the signal is the same, so summing N sweeps multiplies it by N. The noise in each sweep is independent, with random signs and sizes, so in the sum it partly cancels: the variances add, giving a total noise RMS of $\sqrt N$ times one sweep's. Dividing both by N to average, the signal is unchanged and the noise falls to $1/\sqrt N$ of a single sweep's. The amplitude ratio improves by $\sqrt N$, which in power, the way SNR is quoted in dB, is a factor of N, or $10\log_{10}N$ dB.
:::
:::

::: practice

::: check
given: N = 4 | 10 | 16 | 64 | 100 | 256 | 1000
answer: 10*log(N)
unit: dB
tolerance: 0.5%

## SNR gain from averaging {N} records?

::: misses
- [any] $10\log_{10}N$.
:::
:::

::: check
given: tau = 0.01 | 0.03 | 0.1 | 0.3 | 1 | 3
answer: 1/(4*tau)
unit: Hz
tolerance: 0.5%

## ENBW for τ = {tau} s?

::: misses
- [any] $1/(4\tau)$.
:::
:::

::: check
given: en = 3 | 20; B = 50 | 5000
answer: en*sqrt(B)
unit: nV
tolerance: 0.5%

## Noise for {en} nV/√Hz over {B} Hz?

::: misses
- [any] $e_n\sqrt B$.
:::
:::
:::
