<s>
A	O
Savitzky	O
–	O
Golay	O
filter	O
is	O
a	O
digital	O
filter	O
that	O
can	O
be	O
applied	O
to	O
a	O
set	O
of	O
digital	B-General_Concept
data	I-General_Concept
points	O
for	O
the	O
purpose	O
of	O
smoothing	B-Application
the	O
data	O
,	O
that	O
is	O
,	O
to	O
increase	O
the	O
precision	O
of	O
the	O
data	O
without	O
distorting	O
the	O
signal	O
tendency	O
.	O
</s>
<s>
This	O
is	O
achieved	O
,	O
in	O
a	O
process	O
known	O
as	O
convolution	B-Language
,	O
by	O
fitting	O
successive	O
sub-sets	O
of	O
adjacent	O
data	O
points	O
with	O
a	O
low-degree	O
polynomial	O
by	O
the	O
method	O
of	O
linear	B-Algorithm
least	I-Algorithm
squares	I-Algorithm
.	O
</s>
<s>
When	O
the	O
data	O
points	O
are	O
equally	O
spaced	O
,	O
an	O
analytical	O
solution	O
to	O
the	O
least-squares	O
equations	O
can	O
be	O
found	O
,	O
in	O
the	O
form	O
of	O
a	O
single	O
set	O
of	O
"	O
convolution	B-Language
coefficients	O
"	O
that	O
can	O
be	O
applied	O
to	O
all	O
data	O
sub-sets	O
,	O
to	O
give	O
estimates	O
of	O
the	O
smoothed	B-Application
signal	O
,	O
(	O
or	O
derivatives	O
of	O
the	O
smoothed	B-Application
signal	O
)	O
at	O
the	O
central	O
point	O
of	O
each	O
sub-set	O
.	O
</s>
<s>
The	O
method	O
,	O
based	O
on	O
established	O
mathematical	O
procedures	O
,	O
was	O
popularized	O
by	O
Abraham	O
Savitzky	O
and	O
Marcel	O
J	O
.	O
E	O
.	O
Golay	O
,	O
who	O
published	O
tables	O
of	O
convolution	B-Language
coefficients	O
for	O
various	O
polynomials	O
and	O
sub-set	O
sizes	O
in	O
1964	O
.	O
</s>
<s>
Selected	O
convolution	B-Language
coefficients	O
are	O
shown	O
in	O
the	O
tables	O
,	O
below	O
.	O
</s>
<s>
There	O
are	O
numerous	O
applications	O
of	O
smoothing	B-Application
,	O
which	O
is	O
performed	O
primarily	O
to	O
make	O
the	O
data	O
appear	O
to	O
be	O
less	O
noisy	O
than	O
it	O
really	O
is	O
.	O
</s>
<s>
The	O
following	O
are	O
applications	O
of	O
numerical	B-Algorithm
differentiation	I-Algorithm
of	O
data	O
.	O
</s>
<s>
The	O
smoothed	B-Application
curve	O
(	O
red	O
line	O
)	O
and	O
1st	O
derivative	O
(	O
green	O
)	O
were	O
calculated	O
with	O
7-point	O
cubic	O
Savitzky	O
–	O
Golay	O
filters	O
.	O
</s>
<s>
An	O
unweighted	O
moving	O
average	O
filter	O
is	O
the	O
simplest	O
convolution	B-Language
filter	O
.	O
</s>
<s>
It	O
was	O
not	O
included	O
in	O
the	O
Savitzsky-Golay	O
tables	O
of	O
convolution	B-Language
coefficients	O
as	O
all	O
the	O
coefficient	O
values	O
are	O
identical	O
,	O
with	O
the	O
value	O
.	O
</s>
<s>
This	O
solution	O
forms	O
the	O
basis	O
of	O
the	O
convolution	B-Language
method	O
of	O
numerical	B-Algorithm
smoothing	I-Algorithm
and	I-Algorithm
differentiation	I-Algorithm
.	O
</s>
<s>
are	O
obtained	O
by	O
solving	O
the	O
normal	B-Algorithm
equations	I-Algorithm
(	O
bold	O
a	O
represents	O
a	O
vector	O
,	O
bold	O
J	O
represents	O
a	O
matrix	B-Architecture
)	O
.	O
</s>
<s>
where	O
is	O
a	O
Vandermonde	O
matrix	B-Architecture
,	O
that	O
is	O
-th	O
row	O
of	O
has	O
values	O
.	O
</s>
<s>
For	O
example	O
,	O
for	O
a	O
cubic	O
polynomial	O
fitted	O
to	O
5	O
points	O
,	O
z	O
=	O
−2	O
,	O
−1	O
,	O
0	O
,	O
1	O
,	O
2	O
the	O
normal	B-Algorithm
equations	I-Algorithm
are	O
solved	O
as	O
follows	O
.	O
</s>
<s>
The	O
coefficients	O
of	O
y	O
in	O
these	O
expressions	O
are	O
known	O
as	O
convolution	B-Language
coefficients	O
.	O
</s>
<s>
Tables	O
of	O
convolution	B-Language
coefficients	O
,	O
calculated	O
in	O
the	O
same	O
way	O
for	O
m	O
up	O
to	O
25	O
,	O
were	O
published	O
for	O
the	O
Savitzky	O
–	O
Golay	O
smoothing	B-Application
filter	O
in	O
1964	O
,	O
The	O
value	O
of	O
the	O
central	O
point	O
,	O
z	O
=	O
0	O
,	O
is	O
obtained	O
from	O
a	O
single	O
set	O
of	O
coefficients	O
,	O
a0	O
for	O
smoothing	B-Application
,	O
a1	O
for	O
1st	O
derivative	O
etc	O
.	O
</s>
<s>
The	O
numerical	B-Algorithm
derivatives	I-Algorithm
are	O
obtained	O
by	O
differentiating	O
Y	O
.	O
</s>
<s>
This	O
means	O
that	O
the	O
derivatives	O
are	O
calculated	O
for	O
the	O
smoothed	B-Application
data	O
curve	O
.	O
</s>
<s>
give	O
the	O
same	O
coefficients	O
for	O
smoothing	B-Application
and	O
even	O
derivatives	O
.	O
</s>
<s>
The	O
summations	O
in	O
the	O
matrix	B-Architecture
JTJ	O
can	O
be	O
evaluated	O
in	O
closed	B-Algorithm
form	I-Algorithm
,	O
</s>
<s>
so	O
that	O
algebraic	O
formulae	O
can	O
be	O
derived	O
for	O
the	O
convolution	B-Language
coefficients	O
.	O
</s>
<s>
Smoothing	B-Application
,	O
polynomial	O
degree	O
0	O
,	O
1	O
(	O
moving	O
average	O
)	O
:	O
</s>
<s>
Expressions	O
for	O
the	O
convolution	B-Language
coefficients	O
are	O
easily	O
obtained	O
because	O
the	O
normal	B-Algorithm
equations	I-Algorithm
matrix	B-Architecture
,	O
JTJ	O
,	O
is	O
a	O
diagonal	B-Algorithm
matrix	I-Algorithm
as	O
the	O
product	O
of	O
any	O
two	O
orthogonal	O
polynomials	O
is	O
zero	O
by	O
virtue	O
of	O
their	O
mutual	O
orthogonality	O
.	O
</s>
<s>
Therefore	O
,	O
each	O
non-zero	O
element	O
of	O
its	O
inverse	O
is	O
simply	O
the	O
reciprocal	O
the	O
corresponding	O
element	O
in	O
the	O
normal	B-Algorithm
equation	I-Algorithm
matrix	B-Architecture
.	O
</s>
<s>
The	O
whole	O
calculation	O
can	O
be	O
coded	O
in	O
a	O
few	O
lines	O
of	O
PASCAL	B-Application
,	O
a	O
computer	O
language	O
well-adapted	O
for	O
calculations	O
involving	O
recursion	O
.	O
</s>
<s>
Savitzky	O
–	O
Golay	O
filters	O
are	O
most	O
commonly	O
used	O
to	O
obtain	O
the	O
smoothed	B-Application
or	O
derivative	O
value	O
at	O
the	O
central	O
point	O
,	O
z	O
=	O
0	O
,	O
using	O
a	O
single	O
set	O
of	O
convolution	B-Language
coefficients	O
.	O
</s>
<s>
Looking	O
again	O
at	O
the	O
fitting	O
polynomial	O
,	O
it	O
is	O
obvious	O
that	O
data	O
can	O
be	O
calculated	O
for	O
all	O
values	O
of	O
z	O
by	O
using	O
all	O
sets	O
of	O
convolution	B-Language
coefficients	O
for	O
a	O
single	O
polynomial	O
,	O
a0	O
..	O
ak	O
.	O
</s>
<s>
Convolution	B-Language
coefficients	O
for	O
the	O
missing	O
first	O
and	O
last	O
points	O
can	O
also	O
be	O
easily	O
obtained	O
.	O
</s>
<s>
If	O
the	O
same	O
set	O
of	O
diagonal	O
weights	O
is	O
used	O
for	O
all	O
data	O
subsets	O
,	O
,	O
an	O
analytical	O
solution	O
to	O
the	O
normal	B-Algorithm
equations	I-Algorithm
can	O
be	O
written	O
down	O
.	O
</s>
<s>
An	O
explicit	O
expression	O
for	O
the	O
inverse	O
of	O
this	O
matrix	B-Architecture
can	O
be	O
obtained	O
using	O
Cramer	O
's	O
rule	O
.	O
</s>
<s>
Alternatively	O
the	O
coefficients	O
,	O
C	O
,	O
could	O
be	O
calculated	O
in	O
a	O
spreadsheet	O
,	O
employing	O
a	O
built-in	O
matrix	B-Architecture
inversion	O
routine	O
to	O
obtain	O
the	O
inverse	O
of	O
the	O
normal	B-Algorithm
equations	I-Algorithm
matrix	B-Architecture
.	O
</s>
<s>
Two-dimensional	O
smoothing	B-Application
and	O
differentiation	O
can	O
also	O
be	O
applied	O
to	O
tables	O
of	O
data	O
values	O
,	O
such	O
as	O
intensity	O
values	O
in	O
a	O
photographic	O
image	O
which	O
is	O
composed	O
of	O
a	O
rectangular	O
grid	O
of	O
pixels	O
.	O
</s>
<s>
The	O
first	O
row	O
of	O
C	O
contains	O
35	O
convolution	B-Language
coefficients	O
,	O
which	O
can	O
be	O
multiplied	O
with	O
the	O
35	O
data	O
values	O
,	O
respectively	O
,	O
to	O
obtain	O
the	O
polynomial	O
coefficient	O
,	O
which	O
is	O
the	O
smoothed	B-Application
value	O
at	O
the	O
central	O
node	O
of	O
the	O
kernel	O
(	O
i.e.	O
</s>
<s>
Similarly	O
,	O
other	O
rows	O
of	O
C	O
can	O
be	O
multiplied	O
with	O
the	O
35	O
values	O
to	O
obtain	O
other	O
polynomial	O
coefficients	O
,	O
which	O
,	O
in	O
turn	O
,	O
can	O
be	O
used	O
to	O
obtain	O
smoothed	B-Application
values	O
and	O
different	O
smoothed	B-Application
partial	O
derivatives	O
at	O
different	O
nodes	O
.	O
</s>
<s>
Nikitas	O
and	O
Pappa-Louisi	O
showed	O
that	O
depending	O
on	O
the	O
format	O
of	O
the	O
used	O
polynomial	O
,	O
the	O
quality	O
of	O
smoothing	B-Application
may	O
vary	O
significantly	O
.	O
</s>
<s>
because	O
such	O
polynomials	O
can	O
achieve	O
good	O
smoothing	B-Application
both	O
in	O
the	O
central	O
and	O
in	O
the	O
near-boundary	O
regions	O
of	O
a	O
kernel	O
,	O
and	O
therefore	O
they	O
can	O
be	O
confidently	O
used	O
in	O
smoothing	B-Application
both	O
at	O
the	O
internal	O
and	O
at	O
the	O
near-boundary	O
data	O
points	O
of	O
a	O
sampled	O
domain	O
.	O
</s>
<s>
In	O
order	O
to	O
avoid	O
ill-conditioning	O
when	O
solving	O
the	O
least-squares	O
problem	O
,	O
p	O
<	O
m	O
and	O
q	O
<	O
n	O
.	O
For	O
software	O
that	O
calculates	O
the	O
two-dimensional	O
coefficients	O
and	O
for	O
a	O
database	O
of	O
such	O
C	O
's	O
,	O
see	O
the	O
section	O
on	O
multi-dimensional	O
convolution	B-Language
coefficients	O
,	O
below	O
.	O
</s>
<s>
The	O
idea	O
of	O
two-dimensional	O
convolution	B-Language
coefficients	O
can	O
be	O
extended	O
to	O
the	O
higher	O
spatial	O
dimensions	O
as	O
well	O
,	O
in	O
a	O
straightforward	O
manner	O
,	O
by	O
arranging	O
multidimensional	O
distribution	O
of	O
the	O
kernel	O
nodes	O
in	O
a	O
single	O
row	O
.	O
</s>
<s>
has	O
brought	O
forth	O
two	O
open	B-Application
source	I-Application
softwares	I-Application
,	O
Advanced	O
Convolution	B-Language
Coefficient	O
Calculator	O
(	O
ACCC	O
)	O
and	O
Precise	O
Convolution	B-Language
Coefficient	O
Calculator	O
(	O
PCCC	O
)	O
,	O
which	O
handle	O
these	O
accuracy	O
issues	O
adequately	O
.	O
</s>
<s>
The	O
precision	O
of	O
the	O
floating-point	O
numbers	O
is	O
gradually	O
increased	O
in	O
each	O
iteration	O
,	O
by	O
using	O
GNU	B-Application
MPFR	I-Application
.	O
</s>
<s>
If	O
the	O
distance	O
is	O
sufficiently	O
large	O
,	O
the	O
computation	O
yields	O
a	O
highly	O
accurate	O
C	O
.	O
PCCC	O
employs	O
rational	O
number	O
calculations	O
,	O
by	O
using	O
GNU	B-Application
Multiple	I-Application
Precision	I-Application
Arithmetic	I-Application
Library	I-Application
,	O
and	O
yields	O
a	O
fully	O
accurate	O
C	O
,	O
in	O
the	O
rational	O
number	O
format	O
.	O
</s>
<s>
The	O
sum	O
of	O
convolution	B-Language
coefficients	O
for	O
smoothing	B-Application
is	O
equal	O
to	O
one	O
.	O
</s>
<s>
The	O
sum	O
of	O
squared	O
convolution	B-Language
coefficients	O
for	O
smoothing	B-Application
is	O
equal	O
to	O
the	O
value	O
of	O
the	O
central	O
coefficient	O
.	O
</s>
<s>
Smoothing	B-Application
of	O
a	O
function	O
leaves	O
the	O
area	O
under	O
the	O
function	O
unchanged	O
.	O
</s>
<s>
Convolution	B-Language
of	O
a	O
symmetric	O
function	O
with	O
even-derivative	O
coefficients	O
conserves	O
the	O
centre	O
of	O
symmetry	O
.	O
</s>
<s>
It	O
is	O
inevitable	O
that	O
the	O
signal	O
will	O
be	O
distorted	O
in	O
the	O
convolution	B-Language
process	O
.	O
</s>
<s>
From	O
property	O
3	O
above	O
,	O
when	O
data	O
which	O
has	O
a	O
peak	O
is	O
smoothed	B-Application
the	O
peak	O
height	O
will	O
be	O
reduced	O
and	O
the	O
half-width	O
will	O
be	O
increased	O
.	O
</s>
<s>
For	O
example	O
,	O
with	O
a	O
9-point	O
linear	O
function	O
(	O
moving	O
average	O
)	O
two	O
thirds	O
of	O
the	O
noise	O
is	O
removed	O
and	O
with	O
a	O
9-point	O
quadratic/cubic	O
smoothing	B-Application
function	O
only	O
about	O
half	O
the	O
noise	O
is	O
removed	O
.	O
</s>
<s>
Most	O
of	O
the	O
noise	O
remaining	O
is	O
low-frequency	O
noise(see Frequency characteristics of convolution filters, below )	O
.	O
</s>
<s>
Although	O
the	O
moving	O
average	O
function	O
gives	O
the	O
best	O
noise	O
reduction	O
it	O
is	O
unsuitable	O
for	O
smoothing	B-Application
data	O
which	O
has	O
curvature	O
over	O
m	O
points	O
.	O
</s>
<s>
The	O
optimal	O
choice	O
of	O
polynomial	O
order	O
and	O
number	O
of	O
convolution	B-Language
coefficients	O
will	O
be	O
a	O
compromise	O
between	O
noise	O
reduction	O
and	O
distortion	O
.	O
</s>
<s>
One	O
way	O
to	O
mitigate	O
distortion	O
and	O
improve	O
noise	O
removal	O
is	O
to	O
use	O
a	O
filter	O
of	O
smaller	O
width	O
and	O
perform	O
more	O
than	O
one	O
convolution	B-Language
with	O
it	O
.	O
</s>
<s>
For	O
two	O
passes	O
of	O
the	O
same	O
filter	O
this	O
is	O
equivalent	O
to	O
one	O
pass	O
of	O
a	O
filter	O
obtained	O
by	O
convolution	B-Language
of	O
the	O
original	O
filter	O
with	O
itself	O
.	O
</s>
<s>
Convolution	B-Language
maps	O
to	O
multiplication	O
in	O
the	O
Fourier	B-Algorithm
co-domain	B-Algorithm
.	O
</s>
<s>
The	O
plot	O
for	O
a	O
9-point	O
quadratic/cubic	O
smoothing	B-Application
function	O
is	O
typical	O
.	O
</s>
<s>
At	O
very	O
low	O
angle	O
,	O
the	O
plot	O
is	O
almost	O
flat	O
,	O
meaning	O
that	O
low-frequency	O
components	O
of	O
the	O
data	O
will	O
be	O
virtually	O
unchanged	O
by	O
the	O
smoothing	B-Application
operation	O
.	O
</s>
<s>
This	O
shows	O
that	O
the	O
convolution	B-Language
filter	O
can	O
be	O
described	O
as	O
a	O
low-pass	B-Algorithm
filter	I-Algorithm
:	O
the	O
noise	O
that	O
is	O
removed	O
is	O
primarily	O
high-frequency	O
noise	O
and	O
low-frequency	O
noise	O
passes	O
through	O
the	O
filter	O
.	O
</s>
<s>
Some	O
high-frequency	O
noise	O
components	O
are	O
attenuated	O
more	O
than	O
others	O
,	O
as	O
shown	O
by	O
undulations	O
in	O
the	O
Fourier	B-Algorithm
transform	I-Algorithm
at	O
large	O
angles	O
.	O
</s>
<s>
This	O
can	O
give	O
rise	O
to	O
small	O
oscillations	O
in	O
the	O
smoothed	B-Application
data	O
and	O
phase	O
reversal	O
,	O
i.e.	O
,	O
high-frequency	O
oscillations	O
in	O
the	O
data	O
get	O
inverted	O
by	O
Savitzky	O
–	O
Golay	O
filtering	O
.	O
</s>
<s>
Convolution	B-Language
affects	O
the	O
correlation	O
between	O
errors	O
in	O
the	O
data	O
.	O
</s>
<s>
The	O
effect	O
of	O
convolution	B-Language
can	O
be	O
expressed	O
as	O
a	O
linear	O
transformation	O
.	O
</s>
<s>
A	O
will	O
be	O
an	O
identity	B-Algorithm
matrix	I-Algorithm
multiplied	O
by	O
a	O
constant	O
,	O
σ2	O
,	O
the	O
variance	O
at	O
each	O
point	O
.	O
</s>
<s>
After	O
two	O
passes	O
,	O
the	O
standard	B-General_Concept
deviation	I-General_Concept
of	O
the	O
central	O
point	O
has	O
decreased	O
to	O
,	O
compared	O
to	O
0.58σ	O
for	O
one	O
pass	O
.	O
</s>
<s>
The	O
noise	O
reduction	O
is	O
a	O
little	O
less	O
than	O
would	O
be	O
obtained	O
with	O
one	O
pass	O
of	O
a	O
5-point	O
moving	O
average	O
which	O
,	O
under	O
the	O
same	O
conditions	O
,	O
would	O
result	O
in	O
the	O
smoothed	B-Application
points	O
having	O
the	O
smaller	O
standard	B-General_Concept
deviation	I-General_Concept
of	O
0.45σ	O
.	O
</s>
<s>
The	O
advantage	O
obtained	O
by	O
performing	O
two	O
passes	O
with	O
the	O
narrower	O
smoothing	B-Application
function	O
is	O
that	O
it	O
introduces	O
less	O
distortion	O
into	O
the	O
calculated	O
data	O
.	O
</s>
<s>
Compared	O
with	O
other	O
smoothing	B-Application
filters	O
,	O
e.g.	O
</s>
<s>
convolution	B-Language
with	O
a	O
Gaussian	O
or	O
multi-pass	O
moving-average	O
filtering	O
,	O
Savitzky	O
–	O
Golay	O
filters	O
have	O
an	O
initially	O
flatter	O
response	O
and	O
sharper	O
cutoff	O
in	O
the	O
frequency	O
domain	O
,	O
especially	O
for	O
high	O
orders	O
of	O
the	O
fit	O
polynomial	O
(	O
see	O
frequency	O
characteristics	O
)	O
.	O
</s>
<s>
For	O
data	O
with	O
limited	O
signal	B-Algorithm
bandwidth	I-Algorithm
,	O
this	O
means	O
that	O
Savitzky	O
–	O
Golay	O
filtering	O
can	O
provide	O
better	O
signal-to-noise	O
ratio	O
than	O
many	O
other	O
filters	O
;	O
e.g.	O
,	O
peak	O
heights	O
of	O
spectra	O
are	O
better	O
preserved	O
than	O
for	O
other	O
filters	O
with	O
similar	O
noise	O
suppression	O
.	O
</s>
<s>
Alternative	O
smoothing	B-Application
methods	O
that	O
share	O
the	O
advantages	O
of	O
Savitzky	O
–	O
Golay	O
filters	O
and	O
mitigate	O
at	O
least	O
some	O
of	O
their	O
disadvantages	O
are	O
Savitzky	O
–	O
Golay	O
filters	O
with	O
properly	O
chosen	O
fitting	O
weights	O
,	O
Whittaker	O
–	O
Henderson	O
smoothing	B-Application
(	O
a	O
method	O
closely	O
related	O
to	O
smoothing	B-Algorithm
splines	I-Algorithm
)	O
,	O
and	O
convolution	B-Language
with	O
a	O
windowed	B-Language
sinc	B-Algorithm
function	I-Algorithm
.	O
</s>
