Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning NumPy Array

You're reading from  Learning NumPy Array

Product type Book
Published in Jun 2014
Publisher
ISBN-13 9781783983902
Pages 164 pages
Edition 1st Edition
Languages
Author (1):
Ivan Idris Ivan Idris
Profile icon Ivan Idris

Table of Contents (14) Chapters

Learning NumPy Array
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Getting Started with NumPy NumPy Basics Basic Data Analysis with NumPy Simple Predictive Analytics with NumPy Signal Processing Techniques Profiling, Debugging, and Testing The Scientific Python Ecosystem Index

Smoothing functions


Smoothing can help us get rid of noise and outliers in raw data. This, for instance, makes it easier to spot trends in the data. NumPy provides a number of smoothing functions.

Note

These functions can calculate weights in a sliding window as we did in the previous example (for more background information, visit http://en.wikipedia.org/wiki/Window_function).

These functions, except the kaiser function, require only one parameter—the size of the window, which we will set to 22 for the middle cycle of the sunspot data. The kaiser function also needs a beta parameter. With this parameter, the kaiser function can mimic the other functions.

The NumPy documentation recommends a starting value of 14 for the beta parameter, so that is what we are going to use too. The code is straightforward and given as follows (the data here is limited to the last 50 years only for easier comparison in the plots):

import numpy as np
import sys
import matplotlib.pyplot as plt

def smooth(weights...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}