Filters and Noise Optional Assessment of Practical Importance

Rubin H Landau

Sally Haerer, Producer-Director

Based on A Survey of Computational Physics by Landau, Páez, & Bordeianu

with Support from the National Science Foundation

Course: Computational Physics II

1 / 1 Problem: Cleaning Up Noisy a Signal

� � � � � � � � � �����

Problem: What is pure signal?

Two Simple Approaches 1 Autocorrelation functions

2 Digital Filters

Both wide applications

More filters in Wavelet Analysis & Data Compression

2 / 1 Noise Reduction via Autocorrelation (Theory)

Assumption: Noise just adds to signal

Measure = Signal + Noise

� � � � � � � � � y(t) = s(t) + n(t) �����

s(t) = ?

Science: assume simplest (+)

Science: noise ' random( ∞ o F)

Recall “random” sequence; ri ; ri+1

⇒ n(t) not correlated with s(t), n(t) 3 / 1 Correlation Function c(t)

How measure correlation?

y(t) = sin ω, x(t) = sin(nωt + φ) correlated

Z +∞ c(τ) = dt y ∗(t) x(t + τ) (Correlation Function) −∞

Correlated (τ = lag time = variable): Integrand > 0 for some τ ⇒ Constructive interference ⇒ c(τ) → ∞ Not correlated: 2 functions oscillate independently +, - equally likely ⇒ Destructive interference ⇒ c(τ) ' 0

4 / 1 More Correlation Function

Properties Express c, y ∗, x via FT & substitute:

0 Z +∞ eiω τ (FT) c(τ) = dω0 C(ω0)√ (1) −∞ 2π

Z +∞ (Def) c(τ) def= dt y ∗(t) x(t + τ) (2) −∞ √ ⇒ C(ω)= 2π Y ∗(ω)X(ω) (3)

Requires convergence to rearrange Related to theorem (soon)

5 / 1 Special Correlation Function: Autocorrelation

Measure Correlation with Itself: a(τ) Z +∞ a(τ) def= dt y ∗(t) y(t + τ) −∞

To compute: fold or convolute with self:

y(t) = measured signal

Average over time for “all” τ values

a(0) = “large”

6 / 1 Averaging Removes Random Noise from a(t) Proof by substitution

y(t) =s(t) + n(t) (Noisy Signal) (4)

Z +∞ def ∗ ay (τ) = dt y (t) y(t + τ) (Def a(t)) (5) −∞

Z +∞ = dt [s(t)s(t + τ) + s(t)n(t + τ) + n(t)n(t + τ)] −∞

Z +∞ ⇒ ay (τ) ' dt s(t) s(t + τ) = as(τ) QED Magic (6) −∞ √ 2 So As(ω) ' 2π |S(ω)| ∝ Power Spectrum (7)

7 / 1 How Apply to Data?

Start with Noisy signal

2 �� ���� ��� � � � ��� � �� ����� �� � ��� x10 Autocorrelation Function A(tau) � � 1.4 B � A 1.2 � 1.0 � A � 0.8 0.6 � 0.4 � � � � � � � � � � 0 2 4 6 8 10 12 ����� tau (s)

3 x10 Power Spectrum (with Noise) Function y(t) + Noise After Low pass Filter 3.5 10 3.0 C 2.5 8 D P 2.0 6 1.5 y 4 1.0 0.5 2 0.0 0 0 5 10 15 20 25 30 35 40 45 0 2 4 6 8 10 12 Frequency t (s) 2 DFT: a(t) ⇒ A(ω) 1 Compute autocorrelation ⇒ function 3 power spectrum w/o random noise

8 / 1 Autocorrelation Function Exercises (Noise.java)

Example

1 1 2 Signal: s(t) = 1−0.9 sin t ' 1 + 0.9 sin t + (0.9 sin t) ···

2 DFT ⇒ S(ω), Plot |S(ω)|2.

3 Autocorrelation function a(t) of s(t)?

4 Power spectrum a(t) vs |S(ω)|2?

5 Add noise y(ti ) = s(ti ) + α(2ri − 1), 0fuss ≤ α ≤ hide

6 Plot y(t),Y (ω), Power spectrum.

7 a(t) → A(ω).

8 Compare A(ω) to power spectrum. 9 / 1 Filtering with Transforms (Theory)

Action of Filter

Z +∞ g(t) = dτ f (τ) h(t − τ) (8) −∞

def = f (t) ∗ h(t) (analog filter) (9)

def h(t) = unit impulse Greens function response h(0) = max, h(< 0) = 0 R +∞ h(t) = −∞ dτ δ(τ) h(t − τ) ∗ = Convolution

10 / 1 Convolution Theorem

Filter as Convolution

Z +∞ g(t) = dτ f (τ) h(t − τ) (10) −∞ √ G(ω) = 2π F(ω) H(ω) (11)

Proof: FT,δ, R Lowpass: ↓ high ω Simpler in ω than t Highpass: ↓ low ω Digital: response (ωn)

11 / 1 Digital Filters

Filter Coefficients cn = Complete Description

Z +∞ Filter Def: g(t) = dτ f (τ) h(t − τ) (12) −∞

N X Digital Transfer: h(t) = cn δ(t − nτ) (13) n=0

N X ⇒ g(t) = cn f (t − nτ) (14) n=0

cn: integration wts N point DFT + response

12 / 1 Exploration: Windowed Sinc Filters (Filter.java)

Lowpass Filter to Reduce Noise,

Ideal frequency response 3 Windowed-sinc filter kernel 1.0 A A 1.5 m 0.8 m p p 1.0 l 0.6 l i i t 0.4 t 0.5 u u 0.0 d 0.2 d e e 0.0 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 Frequency Time Ideal lowpass Y (ω) = rectangular pulse ⇒ y(t) =

Z +∞  t  sin(πt/2) dω e−iωt rect(ω) = sinc def= −∞ 2 πt/2

⇒ filter out high ω: convolute with sin(ωct)/(ωct) Exercise: Repeat random noise addition using sinc filter

13 / 1