Lab · Lesson 6

Wavelets for engineers

Derive what a wavelet map shows for a steady tone and for a sharp knock, why every mark has the same area, and how to read an amplitude off a map, then size the marks for a fan on a calculator.

Read the whole lesson as notes · every step, derivation and worked example, on one page

1Goal Where we are going

A spectrum says which frequencies are in a signal, not when. A wavelet map says both. This is the map of the fan from the video: a steady hum along the bottom, and a flash each time it knocks.

This lesson derives what that map shows and how to read it. The working builds up below the board; click any heading there to fold it away.

By the end of this lesson we will have derived what a wavelet map shows for the two things a machine signal is made of. A steady tone of amplitude AA at f0f_0 gives a band, the same at every time bb:

∣W(a,b)∣≈A22πa  e−(2πf0a−ω0)2/2|W(a,b)|\approx\frac{A}{2}\sqrt{2\pi a}\;e^{-(2\pi f_0a-\omega_0)^2/2}
← a tone

A sharp knock at t0t_0 gives a flash whose length is set by the row:

∣W(a,b)∣=Ia  e−(t0−b)2/(2a2)|W(a,b)|=\frac{I}{\sqrt a}\;e^{-(t_0-b)^2/(2a^2)}
← a knock

and every mark on the map has the same area, whatever its frequency:

Δt⋅Δf=4ln⁡2π≈0.88\Delta t\cdot\Delta f=\frac{4\ln2}{\pi}\approx0.88
← short and tall at high f, long and flat at low f

Then we size the marks for the fan in the video, and read an amplitude off a map by hand.

2What we already know The tools

Seven facts, lettered (A) to (G). The one doing most of the work is (E): the area under a bell times a turning arrow.

On the board, the shaded area is e−u2/2cos⁡κue^{-u^2/2}\cos\kappa u (the real part; the imaginary part cancels). Drag κ\kappa and compare the area with 2πe−κ2/2\sqrt{2\pi}e^{-\kappa^2/2}.

The Fourier transform, the continuous form of Lesson 4’s DFT: the signal is matched against an arrow turning at ff:

X(f)=∫−∞∞x(t) e−i2πft dtX(f)=\int_{-\infty}^{\infty}x(t)\,e^{-i2\pi ft}\,dt
(A)

Euler, as in Lesson 5: a cosine is two arrows, and an arrow has length 1:

cos⁡θ=12eiθ+12e−iθ,∣eiθ∣=1\cos\theta=\tfrac12e^{i\theta}+\tfrac12e^{-i\theta},\qquad |e^{i\theta}|=1
(B)

A change of variable. If u=(t−b)/au=(t-b)/a, then

t=b+au,dt=a dut=b+au,\qquad dt=a\,du
(C)

An arrow eiθ(t)e^{i\theta(t)} turns at dθ/dtd\theta/dt radians per second, and

ω=2πf\omega=2\pi f
(D)← radians per second from hertz

The Gaussian integral, for any real κ\kappa. Complete the square, −u22+iκu=−12(u−iκ)2−κ22-\tfrac{u^2}{2}+i\kappa u=-\tfrac12(u-i\kappa)^2-\tfrac{\kappa^2}{2}; the shifted bell still has area 2π\sqrt{2\pi}:

∫−∞∞e−u2/2 eiκu du=2π  e−κ2/2\int_{-\infty}^{\infty}e^{-u^2/2}\,e^{i\kappa u}\,du=\sqrt{2\pi}\;e^{-\kappa^2/2}
(E)← check it on the board

An impulse picks out one value of whatever it multiplies:

∫−∞∞δ(t−t0) g(t) dt=g(t0)\int_{-\infty}^{\infty}\delta(t-t_0)\,g(t)\,dt=g(t_0)
(F)

And a bell falls to half its height at

e−x2/2=12  ⟺  x=2ln⁡2=1.177e^{-x^2/2}=\tfrac12\iff x=\sqrt{2\ln2}=1.177
(G)

3Derivation The wavelet and its copies

One wave inside a bell, slid to a time bb and stretched by a scale aa. The wavelet transform W(a,b)W(a,b) is how well the signal matches each copy.

Drag the frequency: the copy gets shorter as it gets faster, but keeps the same shape.

A wavelet is a short wave inside a bell. The Morlet wavelet is an arrow (B) turning at ω0\omega_0 inside a Gaussian:

ψ(u)=e−u2/2 eiω0u,ω0=6\psi(u)=e^{-u^2/2}\,e^{i\omega_0u},\qquad \omega_0=6
(1)← its real part is on the board

To use it we slide it to a time bb and stretch it by a scale aa, in seconds. Writing u=(t−b)/au=(t-b)/a as in (C):

ψa,b(t)=1a ψ ⁣(t−ba)\psi_{a,b}(t)=\frac{1}{\sqrt a}\,\psi\!\Big(\frac{t-b}{a}\Big)
(2)← centred at b, a times wider

The 1/a1/\sqrt a gives every copy the same energy. By (C), with ∣eiθ∣=1|e^{i\theta}|=1 and ∫e−u2du=π\int e^{-u^2}du=\sqrt\pi:

∫∣ψa,b(t)∣2dt=1a∫e−(t−b)2/a2 dt=1a⋅aπ=π\int|\psi_{a,b}(t)|^2dt=\frac1a\int e^{-(t-b)^2/a^2}\,dt=\frac1a\cdot a\sqrt\pi=\sqrt\pi
(3)← the same for every a

The wavelet transform matches the signal against each copy, exactly as (A) matches it against an arrow:

W(a,b)=∫x(t) ψa,b∗(t) dt=1a∫x(t) e−(t−b)2/(2a2) e−iω0(t−b)/a dtW(a,b)=\int x(t)\,\psi^{*}_{a,b}(t)\,dt=\frac{1}{\sqrt a}\int x(t)\,e^{-(t-b)^2/(2a^2)}\,e^{-i\omega_0(t-b)/a}\,dt
(4)← one number per (a, b)

The star is the complex conjugate: it turns the arrow backwards, as the minus sign does in (A).

4Derivation Each scale is a frequency

The arrow inside a copy turns at ω0/a\omega_0/a radians per second, so the scale aa and the frequency ff are the same thing in different units.

Every copy holds about one cycle per aa: fast rows get a short burst, slow rows a long one.

Inside (4), the arrow’s angle is ω0(t−b)/a\omega_0(t-b)/a. It turns at ω0/a\omega_0/a radians per second, so by (D)

2πf=ω0a⇒f=ω02πa,a=ω02πf2\pi f=\frac{\omega_0}{a}\qquad\Rightarrow\qquad f=\frac{\omega_0}{2\pi a},\qquad a=\frac{\omega_0}{2\pi f}
(5)← each scale is a frequency

For example, the 25 Hz row of a map uses

a=62π×25=6157.08=0.0382 s=38.2 msa=\frac{6}{2\pi\times25}=\frac{6}{157.08}=0.0382\ \text{s}=38.2\ \text{ms}
(6)

The bell in (4) is e−(t−b)2/(2a2)e^{-(t-b)^2/(2a^2)}: its width is proportional to aa. Cycles per second times seconds of bell:

f⋅a=ω02π=0.955f\cdot a=\frac{\omega_0}{2\pi}=0.955
(7)← about one cycle per a, at every scale

So every copy holds the same number of wiggles. A fast row gets a short burst, a slow row a long one. Slide the frequency on the board.

5Derivation A steady tone

Put one tone through every row. Each row answers with a bell-shaped strength (11), largest in the row whose frequency matches the tone, and the same at every time bb.

On the board, each row’s answer divided by the peak. Move the tone and watch the half-height band stay ±20% wide.

Feed in one steady tone of amplitude AA, at Ω=2πf0\Omega=2\pi f_0 radians per second. By (B) it is two arrows:

x(t)=Acos⁡(Ωt+φ)=A2eiφeiΩt+A2e−iφe−iΩtx(t)=A\cos(\Omega t+\varphi)=\tfrac{A}{2}e^{i\varphi}e^{i\Omega t}+\tfrac{A}{2}e^{-i\varphi}e^{-i\Omega t}
(8)

Put the forward arrow into (4) and change variable by (C), t=b+aut=b+au, dt=a dudt=a\,du:

W+=A2eiφ1a∫eiΩ(b+au) e−u2/2 e−iω0u a du=A2eiφeiΩba∫e−u2/2 ei(aΩ−ω0)u duW_+=\frac{A}{2}e^{i\varphi}\frac{1}{\sqrt a}\int e^{i\Omega(b+au)}\,e^{-u^2/2}\,e^{-i\omega_0u}\,a\,du=\frac{A}{2}e^{i\varphi}e^{i\Omega b}\sqrt a\int e^{-u^2/2}\,e^{i(a\Omega-\omega_0)u}\,du
(9)

The integral is (E) with κ=aΩ−ω0\kappa=a\Omega-\omega_0:

W+=A2eiφeiΩb2πa  e−(aΩ−ω0)2/2W_+=\frac{A}{2}e^{i\varphi}e^{i\Omega b}\sqrt{2\pi a}\;e^{-(a\Omega-\omega_0)^2/2}
(10)

The backward arrow gives the same with κ=−aΩ−ω0\kappa=-a\Omega-\omega_0. Near the peak aΩ≈ω0a\Omega\approx\omega_0, so κ≈−12\kappa\approx-12 and e−72e^{-72} is nothing. Set it aside, as in Lesson 5. Take the size, with ∣eiφ∣=∣eiΩb∣=1|e^{i\varphi}|=|e^{i\Omega b}|=1:

∣W(a,b)∣≈A22πa  e−(aΩ−ω0)2/2|W(a,b)|\approx\frac{A}{2}\sqrt{2\pi a}\;e^{-(a\Omega-\omega_0)^2/2}
(11)← a tone

No bb is left in (11): a steady tone is a steady band across the map. It is brightest where aΩ=ω0a\Omega=\omega_0, that is where the row’s frequency (5) equals the tone’s. There the exponential is 1:

∣W∣peak=A22πa⇒A=2 ∣W∣peak2πa|W|_{\text{peak}}=\frac{A}{2}\sqrt{2\pi a}\qquad\Rightarrow\qquad A=\frac{2\,|W|_{\text{peak}}}{\sqrt{2\pi a}}
(12)← reading an amplitude off the map

6Derivation A sharp knock

A knock contains every frequency, so every row lights up, but each one for a time proportional to its scale. The map of one knock is a cone pointing at the moment it happened.

The board is (15), drawn for one knock at the centre.

Now the opposite kind of signal: one sharp knock at t0t_0, idealised as an impulse of strength II:

x(t)=I δ(t−t0)x(t)=I\,\delta(t-t_0)
(13)

Put it into (4). By (F) the integral just evaluates the wavelet at t0t_0:

W(a,b)=Ia e−(t0−b)2/(2a2) e−iω0(t0−b)/aW(a,b)=\frac{I}{\sqrt a}\,e^{-(t_0-b)^2/(2a^2)}\,e^{-i\omega_0(t_0-b)/a}
(14)

Take the size:

∣W(a,b)∣=Ia e−(t0−b)2/(2a2)|W(a,b)|=\frac{I}{\sqrt a}\,e^{-(t_0-b)^2/(2a^2)}
(15)← a knock

Every row lights up, because a knock contains every frequency. But each row lights only for a time proportional to its aa: a short flash in the fast rows, a long smear in the slow ones. On the map a knock is a cone pointing at t0t_0.

7What it means Every mark has the same area

Measured at half height, a mark is 2.355a2.355a long and 0.39f0.39f tall. Multiply, and aa cancels: every mark on a wavelet map has the same area, 0.88. The board shows rows at 20, 40, 80, 160 and 320 Hz.

Switch to the short-time FFT: its marks have the same area too, but one shape for every row.

How big is each mark? Measure it at half height, (G).

In time, from (15): half height where ∣t0−b∣/a=1.177|t_0-b|/a=1.177. The full width of a knock’s flash is

Δt=2×1.177 a=2.355 a\Delta t=2\times1.177\,a=2.355\,a
(16)

In frequency, from (11): fix a row ff and ask which tones f0f_0 it hears at half height or more. By (5), aΩ=ω0f0/fa\Omega=\omega_0f_0/f, so the condition ∣aΩ−ω0∣≤1.177|a\Omega-\omega_0|\le1.177 becomes

∣ω0f0f−ω0∣≤1.177  ⟺  ∣f0−f∣≤1.177ω0 f=0.196 f\Big|\frac{\omega_0f_0}{f}-\omega_0\Big|\le1.177\iff|f_0-f|\le\frac{1.177}{\omega_0}\,f=0.196\,f
(17)
Δf=2×0.196 f=2.355 fω0\Delta f=2\times0.196\,f=\frac{2.355\,f}{\omega_0}
(18)← a fixed fraction: ±20% with ω₀ = 6

Multiply (16) and (18), using f=ω0/(2πa)f=\omega_0/(2\pi a) from (5):

Δt⋅Δf=2.355 a⋅2.3552πa=(22ln⁡2)22π=4ln⁡2π=0.88\Delta t\cdot\Delta f=2.355\,a\cdot\frac{2.355}{2\pi a}=\frac{(2\sqrt{2\ln2})^2}{2\pi}=\frac{4\ln2}{\pi}=0.88
(19)← no a left

Every mark on a wavelet map has the same area. What changes is its shape: tall and thin in the fast rows, short and wide in the slow ones. A short-time FFT uses one window for every row, so all its marks are the same shape. That is the whole difference.

8What it means Choosing ω₀

ω0\omega_0 sets how many wiggles sit under the bell. More wiggles: sharper in frequency, longer in time. The area of a mark does not change.

Below about 5 the wavelet no longer averages to zero. 6 is the usual choice.

Both widths contain ω0\omega_0. Put a=ω0/(2πf)a=\omega_0/(2\pi f) into (16), and look again at (18):

Δt=2.355 ω02πf=0.375 ω0f,Δff=2.355ω0\Delta t=\frac{2.355\,\omega_0}{2\pi f}=\frac{0.375\,\omega_0}{f},\qquad \frac{\Delta f}{f}=\frac{2.355}{\omega_0}
(20)

A bigger ω0\omega_0 puts more wiggles under the bell (7): sharper in frequency, blurrier in time. The product (19) does not move. It is the short-time FFT’s trade again, but set once as a fraction of ff, not as a fixed number of hertz.

Why not make ω0\omega_0 small? A wavelet must average to zero, or it answers a constant offset. Use (E) on (1) with κ=ω0\kappa=\omega_0:

∫ψ(u) du=2π  e−ω02/2\int\psi(u)\,du=\sqrt{2\pi}\;e^{-\omega_0^2/2}
(21)← 4×10⁻⁸ at ω₀ = 6, but 0.03 at ω₀ = 3

ω0=6\omega_0=6 is the usual choice (Torrence and Compo, 1998): as short as it can be while (21) stays negligible.

9Worked example 1 The hum and the knock

The fan from the video: 1,500 rpm, a 25 Hz hum, and a knock once per turn that rings near 400 Hz. Size the marks by hand.

The dashed outlines on the map are the half-height sizes from the working: one knock at 400 Hz, and the same knock as the 25 Hz row would see it.

Worked example 1. A fan runs at 1500 rpm. It hums at 1X, and something knocks once per turn, ringing near 400 Hz. With ω0=6\omega_0=6: how big are the marks for the hum and for each knock, and do the knocks show up separately?

f1X=150060=25 Hz,one turn=601500=0.040 s=40 msf_{1X}=\frac{1500}{60}=25\ \text{Hz},\qquad \text{one turn}=\frac{60}{1500}=0.040\ \text{s}=40\ \text{ms}
(22)

The scale of each row, by (5):

a25=62π×25=38.2 ms,a400=62π×400=62513.3=2.387 msa_{25}=\frac{6}{2\pi\times25}=38.2\ \text{ms},\qquad a_{400}=\frac{6}{2\pi\times400}=\frac{6}{2513.3}=2.387\ \text{ms}
(23)

The time width of a flash, by (16):

Δt25=2.355×38.2=89.9 ms,Δt400=2.355×2.387=5.62 ms\Delta t_{25}=2.355\times38.2=89.9\ \text{ms},\qquad \Delta t_{400}=2.355\times2.387=5.62\ \text{ms}
(24)

The band each row hears, by (17) and (18):

25±0.196×25=25±4.9 Hz,400±0.196×400=400±78 Hz25\pm0.196\times25=25\pm4.9\ \text{Hz},\qquad 400\pm0.196\times400=400\pm78\ \text{Hz}
(25)

At 400 Hz each knock is a flash 5.6 ms wide, and the knocks are 40 ms apart: 7 times the width, so they show as separate flashes, one per turn. In the 25 Hz row the same knocks would each last 90 ms, more than twice the gap, and run together. But that row pins the hum to 25 Hz ± 5 Hz.

No single short-time FFT does both. To split knocks 40 ms apart it needs a window shorter than 40 ms, and then by Lesson 5 its bins are at least 1/0.040=251/0.040=25 Hz apart: the hum sits in bin 1, next to DC, with nothing around it.

10Worked example 2 Equally bright, not equally big

Two steady bands on one map, equally bright. With the 1/a1/\sqrt a convention the slow one is four times smaller than it looks.

Switch the convention on the board: with 1/a1/a, equal amplitudes are equally bright.

Worked example 2. On the same fan’s map, the 25 Hz band and a steady 400 Hz gear-mesh band are equally bright: both read ∣W∣=0.30|W|=0.30 mm/s·√s. Which vibration is bigger?

By (12) we need 2πa\sqrt{2\pi a} for each row, with aa from (23):

2π×0.0382=0.24=0.4899,2π×0.002387=0.015=0.1225\sqrt{2\pi\times0.0382}=\sqrt{0.24}=0.4899,\qquad \sqrt{2\pi\times0.002387}=\sqrt{0.015}=0.1225
(26)
A25=2×0.300.4899=1.22 mm/s,A400=2×0.300.1225=4.9 mm/sA_{25}=\frac{2\times0.30}{0.4899}=1.22\ \text{mm/s},\qquad A_{400}=\frac{2\times0.30}{0.1225}=4.9\ \text{mm/s}
(27)

Equally bright, but the 400 Hz vibration is four times bigger:

A400A25=a25a400=40025=4\frac{A_{400}}{A_{25}}=\sqrt{\frac{a_{25}}{a_{400}}}=\sqrt{\frac{400}{25}}=4
(28)← slow rows look brighter than they are

With the 1/a1/\sqrt a of (2), a reading grows like a\sqrt a. Some tools use 1/a1/a instead, which makes equal amplitudes equally bright. Check which one yours uses before reading amplitudes off a map, and use (12) when it is 1/a1/\sqrt a.

11Your turn Try it with a calculator

Your turn. In the interactive lesson above, this step gives you a new signal each time, checks your answers and writes out the full working, line by line.

12Summary On one card

Four boxed results. Scale is frequency; a tone is a band whose brightness gives its amplitude; a knock is a cone; and every mark has the same area, 0.88.

Next: sidebands, the twins a slow wobble puts around a fast tone.

Everything in this lesson on one card (Morlet wavelet, ω0=6\omega_0=6):

f=ω02πaf=\frac{\omega_0}{2\pi a}
← scale and frequency, (5)
tone: ∣W∣≈A22πa e−(2πf0a−ω0)2/2,A=2∣W∣peak2πa\text{tone: }|W|\approx\tfrac{A}{2}\sqrt{2\pi a}\,e^{-(2\pi f_0a-\omega_0)^2/2},\qquad A=\frac{2|W|_{\text{peak}}}{\sqrt{2\pi a}}
← (11), (12)
knock: ∣W∣=Ia e−(t0−b)2/(2a2)\text{knock: }|W|=\frac{I}{\sqrt a}\,e^{-(t_0-b)^2/(2a^2)}
← (15)
Δt=2.355 a,Δf=0.39 f,Δt⋅Δf=0.88\Delta t=2.355\,a,\qquad \Delta f=0.39\,f,\qquad \Delta t\cdot\Delta f=0.88
← (16), (18), (19)

A wavelet map answers which frequency and when. Its marks all have the same area: short bursts for fast things, long ones for slow things.