Nonlinear Digital Filtering with Python An Introduction 1st Edition Digital Download
Nonlinear Digital Filtering with Python An Introduction 1st Edition Digital Download
Edition
Visit the link below to download the full version of this book:
https://medipdf.com/product/nonlinear-digital-filtering-with-python-an-introduct
ion-1st-edition/
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts
have been made to publish reliable data and information, but the author and publisher cannot assume
responsibility for the validity of all materials or the consequences of their use. The authors and publishers
have attempted to trace the copyright holders of all material reproduced in this publication and apologize to
copyright holders if permission to publish in this form has not been obtained. If any copyright material has
not been acknowledged please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmit-
ted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented,
including photocopying, microfilming, and recording, or in any information storage or retrieval system,
without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.
com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood
Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and
registration for a variety of users. For organizations that have been granted a photocopy license by the CCC,
a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used
only for identification and explanation without intent to infringe.
Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com
Contents
Preface ix
Authors xiii
1 Introduction 1
1.1 Linear versus nonlinear filters: an example . . . . . . . . . . . . . 2
1.2 Why nonlinearity? Data cleaning filters . . . . . . . . . . . . . . 10
1.3 The many forms of nonlinearity . . . . . . . . . . . . . . . . . . . 14
1.3.1 A simple nonlinear filter taxonomy . . . . . . . . . . . . . 15
1.3.2 Recursive filters: instability and chaos . . . . . . . . . . . 17
1.4 Python and reproducible research . . . . . . . . . . . . . . . . . . 19
1.4.1 A very brief introduction to Python . . . . . . . . . . . . 20
1.4.2 Reproducible research . . . . . . . . . . . . . . . . . . . . 21
1.4.3 How this book was developed . . . . . . . . . . . . . . . . 24
1.5 Organization of this book . . . . . . . . . . . . . . . . . . . . . . 25
2 Python 27
2.1 A high-level overview of the language . . . . . . . . . . . . . . . . 27
2.1.1 How Python programs work . . . . . . . . . . . . . . . . . 28
2.1.2 Using Python interactively . . . . . . . . . . . . . . . . . 28
2.1.3 Using Python from the command prompt . . . . . . . . . 32
2.2 Key language elements . . . . . . . . . . . . . . . . . . . . . . . . 33
2.2.1 The general structure of Python . . . . . . . . . . . . . . 34
2.2.2 Object types . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.2.3 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.2.4 Lists: a key data type . . . . . . . . . . . . . . . . . . . . 39
2.2.5 Tuples: immutable lists . . . . . . . . . . . . . . . . . . . 41
2.2.6 Character strings . . . . . . . . . . . . . . . . . . . . . . . 42
2.2.7 Dictionaries: another key data type . . . . . . . . . . . . 45
2.2.8 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.2.9 Control structures . . . . . . . . . . . . . . . . . . . . . . 49
2.2.10 Input and output . . . . . . . . . . . . . . . . . . . . . . . 53
2.3 Caveat emptor: a few Python quirks . . . . . . . . . . . . . . . . 58
2.3.1 In-place operations, side-effects, and None returns . . . . . 58
v
© 2016 by Taylor & Francis Group, LLC
i i
i i
i i
vi CONTENTS
i i
i i
CONTENTS vii
i i
i i
viii CONTENTS
Bibliography 273
Index 283
i i
i i
Preface
Linear filters that separate signals into components based on their frequency
content play an essential role in the theory and practice of electrical engineer-
ing. Historically, the linearity of these filters has been exploited heavily in the
development of theoretical characterizations and practical design rules. Unfor-
tunately, not all practical signal separation problems are amenable to linear
solutions: the data cleaning problem that provides the central motivation for
this book is a case in point. There, localized “spikes,” “glitches,” or “impul-
sive noise” cannot be effectively removed from other signals using linear filters.
In fact, this inability is a direct consequence of linearity, as demonstrated in
Chapter 1.
Fortunately, a number of nonlinear digital filters have been developed to
address these problems, and research in this area remains active. A classic
example is the standard median filter, proposed by John Tukey in a confer-
ence paper in 1974. This filter turns out to be extremely effective in removing
impulsive “spikes” from signals, but in many applications it also introduces un-
acceptable distortion in the underlying signal components we wish to preserve.
These two characteristics of the median filter have led to the development of
many extensions that attempt to retain the median filter’s effectiveness against
impulsive noise, while reducing its tendency to distort signal components of
interest. Because of the central role the class of median-based filters plays in
practial applications, this book devotes an entire chapter to this class, including
such extensions of the standard median filter as weighted median filters, recur-
sive median filters, recursive weighted median filters, and further generalizations
like the class of stack filters.
A key practical challenge in the analysis of these filters and the design of new
ones is their nonlinearity. Specifically, linearity represents an extremely pow-
erful mathematical condition that has led to remarkably complete and useful
characterizations of linear filters. Removing this mathematical constraint gives
us tremendous additional flexibility in how the resulting filters can behave, but
it introduces equally tremendous obstacles to their analysis and design. In par-
ticular, while the class of linear, time-invariant digital filters exhibits essentially
complete and essentially equivalent behavioral and structural characterizations,
this is no longer true for the class of nonlinear digital filters. That is, the prin-
ciple of superposition describes how linear filters behave, and this behavioral
description leads directly to the convolution representation of these filters in
ix
© 2016 by Taylor & Francis Group, LLC
i i
i i
i i
x PREFACE
i i
i i
xi
both distinct and much harder to characterize in the nonlinear case. In addi-
tion, many nonlinear recursive filters can exhibit highly undesirable behavior like
chaotic responses to simple input changes (e.g., steps or impulses), something
nonrecursive nonlinear digital filters are immune to. Beyond explaining why
most nonlinear digital filters now in use are nonrecursive—the recursive median
filter is a notable exception, discussed in both Chapters 4 and 7—a key motiva-
tion for including a chapter on recursive nonlinear filters here is to highlight an
extremely challenging but potentially equally promising research frontier. That
is, recursive linear filters are known to exhibit a number of practial advantages
over their nonrecursive counterparts. If a class of recursive nonlinear filters
could be identified that was immune to the worst forms of pathological behavior
described in Chapter 7, it might form the basis for novel new nonlinear filter
designs with characteristics superior to anything known today.
Without question, the most popular software environment for digital filter
research and design is MATLAB. Why, then, does this book advocate Python?
First, while excellent, MATLAB is a commercial product with a non-negligible
cost, while Python is a free, open-source computing environment. Although
the level of specialized support for digital filter design is much more extensive
in MATLAB, there is some support in Python (e.g., the scipy package sup-
ports linear digital filter design), and this support is growing (indeed, this book
represents a small contribution). Second, MATLAB was developed to support
mathematical computations based on linear algebra and related notions, while
Python is a general-purpose programming language like Java or C, with an
enormous variety of support packages available to extend the language’s ba-
sic capabilities: as of 29-March-2015, the Python package index (PyPI) listed
57,266 add-on packages, a number that grows daily. These packages support
everything from machine learning tools (e.g., in the scikit-learn package) and
natural language processing (e.g., in the nltk package), to web scraping (e.g.,
with the scrapy package) and HTML parsing (e.g., with the BeautifulSoup
package). In addition, Python has extensive capabilities as an operating system-
independent scripting language (e.g., file management, scheduling tasks, etc.),
with extensive support for website development. Finally, Python also provides
substantial and growing support for reproducible research or dynamic document
development, creating documents that contain text, computational results, and
the code used to obtain those results. This last capability was used in the prepa-
ration of this book and it offers enormous time savings when minor revisions
are required, a point discussed further in Chapter 1. Python implementations
of the most important digital filters discussed in this book are included, and
Chapter 2 presents an essential introduction to Python programming for those
with little or no prior Python experience.
This book is intended as either a textbook or a reference for self-study. As
a textbook, the material presented here would be appropriate for an introduc-
tory course on nonlinear digital filters, at either the advanced undergraduate or
the beginning graduate level. As a reference for self-study, this book should be
useful to those interested in implementing, developing, and using data cleaning
filters for dynamic data analysis or time-series modeling. Specific application
i i
i i
xii PREFACE
i i
i i
Authors
xiii
© 2016 by Taylor & Francis Group, LLC
i i
i i
i i
xiv AUTHORS
Chairman of the DSP Technical Committee of the IEEE Circuits and Systems
Society. He was Honorary Guest Professor of Jilin University, China (2005–
2010). He served as Distinguished Lecturer for the IEEE Circuits and Systems
Society in 2004–2005, and is a Past-Chairman of the IEEE-EURASIP Nonlinear
Signal and Image Processing Board. He was Chairman of the Algorithm Group
of the Eurpean Commisson COST 211quat, served as Associate Editor of the
IEEE Transactions on Image Processing, and was Guest Editor of Multimedia
Tools and Applications and the European Journal Applied Signal Processing.
He is the past Chairman of the IEEE Finland Section and the IEEE SP/CAS
Finland Chapter. He was also Chairman and Technical Program Chair of many
national and international conferences and workshops. He is a member of the
IEEE Signal Processing (SP) and Circuits and Systems (CAS) societies.
Dr. Gabbouj was recipient of the 2012 Nokia Foundation Visiting Professor
Award, the 2005 Nokia Foundation Recognition Award, and many best-paper
awards. He has co-authored over 600 publications and supervised 40 PhD theses.
i i
i i
Chapter 1
Introduction
The title of this book immediately raises the following three questions:
1. Why digital filters?
Signal processing is one of the core areas of electrical engineer-
ing, emerging from advances central to the development of radio,
television, and other forms of electronic communication. One of
the key subject areas within this field is the design and appli-
cation of filters, devices that separate signal components (e.g.,
extracting the signal transmitted by the radio station you want
to listen to from others around it). With the advent and sub-
sequent miniaturization of computers, digital filter implementa-
tions became increasingly practical and widely applied.
2. Why nonlinear digital filters?
The theory of linear filters is well-developed and provides an
extremely powerful foundation for the analysis and design of
practical filters, both digital and analog. Not all filtering prob-
lems have adequate linear solutions, however: a case in point is
the data cleaning problem introduced in this chapter that mo-
tivates much of the work presented in this book. Because the
class of “nonlinear filters” is vastly more heterogeneous than the
class of “linear filters,” there is no general theory analogous to
that for linear filters. The primary objective of this book is to
present a collection of ideas and techniques that are useful in
the design and application of nonlinear digital filters.
3. Why Python?
Without question, the primary software environment used in
signal processing research is MATLAB, a commercial product
1
© 2016 by Taylor & Francis Group, LLC
i i
i i
i i
2 CHAPTER 1. INTRODUCTION
for some nonnegative integer K and some function Φ(·) that maps 2K + 1
i i