Smoothing Functions: Paul Seidel

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Smoothing functions

Paul Seidel

18.01 Lecture Notes, Fall 2011

Example. Suppose we are designing a garage door opener. Once the user trig-
gers it, the opener will start sending a constant current to the motor opening
the door, so the dependence of the current f (t) on the time t is a jump function:

(
0 t<0
f (t) =
1 t > 0.

However, the sudden start causes the door to vibrate (because a function with a
jump has a lot of high-frequency components), and that causes the mechanics to
wear out quickly.

Example. We are building a railroad track. It shifts from a straight line to a


curve: (
1 t≤0
f (t) = √ 2
1 − t 0 < t < 1.
The sudden onset of the centrifugal force experienced as you enter the curve
makes passengers lose their balance. The problem here is that
(
00 0 t<0
f (t) = 2 −3/2
−(1 − x ) t>0

has a jump at t = 0. In classical railroad engineering, one avoids this by using


so-called “train track transition curves” which are complicated functions that
transition from a straight line to a circle, and which are at least three times
differentiable.
Example. You have an old sound recording that has been badly digitized (only
8 volume levels).

1
If you play this straight out of speakers, the high frequency components cause
noise (crackle). How do you produce a good smoothed out analog signal?
Example. You have a photograph that’s very sharp and detailed, and would like
to give it a “soft-focus” slightly blurry tone (let’s say it’s your wedding picture).
Or, you have a photograph that’s been dot-printed in an old newspaper and would
like to erase the dots.
Question. How we can approach such problems systematically? More precisely,
given a function f (x), how we can we “smooth it out” to get a function which
is not too different, but better-behaved with respect to differentiation?

The simplest approach is the method of moving averages:

Definition. Let f (x) be a function. Fix some window size s > 0. The moving
average of f is the function Af (x) defined by
Z x+s/2
1
Af (x) = f (t) dt.
s x−s/2

A is our “averaging operator”. This is an example of a functional transform: it


takes one function f and spits out another function Af . The 1/s term ensures
that if f is a constant, then Af is the same constant.
Example. Let’s apply it to a jump function
(
0 x<0
f (x) =
1 x>0

The moving average is a piecewise linear function:



0
 x < −s/2
Af (x) = 1 x > s/2

x/s + 1/2 −s/2 ≤ x ≤ s/2

This is now continuous (but not yet differentiable).

2
We can apply the moving average several times in order to improve the behaviour
of a function. However, it is possible to make operators which work better in
a single step. For instance, consider the following triangular weighted moving
average:
Z x+s/2
W f (x) = w(x − t)f (t)dt
x−s/2

where the weight function is


(
4x/s2 + 2/s −s/2 ≤ x ≤ 0,
w(x) =
2/s − 4x/s2 0 ≤ x ≤ s/2

If we apply that to the same jump function as before, the outcome is piecewise
quadratic: 

 0 < x < −s/2,
2(x/s + 1/2)2

−s/2 ≤ x ≤ 0,
W f (x) =
1 − 2(x/s − 1/2)2
 0 ≤ x ≤ s/2,

1 x > s/2.

Let’s take the case where 0 ≤ x ≤ s/2. Then,


Z x+s/2 Z −s/2
W f (x) = w(x − t)dt = − w(u)du
0 x
Z x
= w(u)du
−s/2
Z 0 Z x
= w(u)du + w(u)du
−s/2 0
1 2x 2x2  12 2x 2x2 
= + − 2 =1− − 2 .
2 s s − s s

An even more successful method, which turns any (integrable) function into an
infinitely differentiable (hence perfectly smooth) one is the Gaussian filter or
Gaussian blur, which is
Z ∞
Gf (x) = g(x − t)f (t)dt
−∞

where g is just the Gaussian probability density function,


1 x2
g(x) = √ e− 2s2
s 2π
for some constant s > 0 (the higher the constant, the more blurring). This
corresponds to an “infinite window”, but since h decreases very quickly, in
practice one can cut off the infinite tails the integral and only incur a small
error.

3
Objection. Of course, the original example wasn’t realistic. There’s no such
thing as an electrical motor that goes from zero to full power instantaneously!
That is true, but it does not make our discussion meaningless. In many cases,
components of a physical system perform what’s effectively a smoothing pro-
cess all by themselves, since the (macroscopic) physical laws don’t allow jumps.
However, if we didn’t explicitly require or design this, the precise form of the
resulting smoothing will be unknown to us, so we don’t know how it depends on
other parameters. For instance, in the case of a train track, some shape may be
good enough up to a certain speed, and cause too much wear and tear for faster
trains; but unless we’ve understood the underlying phenomenon, we wouldn’t be
able to control it.

You might also like