NumPy Cookbook
Over 70 interesting recipes for learning the Python open
source mathematical library, NumPy
Ivan Idris
BIRMINGHAM - MUMBAI
NumPy Cookbook
Copyright © 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the publisher,
except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly or
indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies
and products mentioned in this book by the appropriate use of capitals. However, Packt
Publishing cannot guarantee the accuracy of this information.
First published: October 2012
Production Reference: 1181012
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-849518-92-5
www.packtpub.com
Cover Image by Avishek Roy ()
Credits
Author
Ivan Idris
Reviewers
Alexandre Devert
Project Coordinator
Vishal Bodwani
Proofreader
Clyde Jenkins
Ludovico Fischer
Ryan R. Rosario
Acquisition Editor
Usha Iyer
Lead Technical Editor
Indexer
Monica Ajmera Mehta
Production Coordinators
Arvindkumar Gupta
Manu Joseph
Ankita Shashi
Cover Work
Technical Editors
Merin Jose
Rohit Rajgor
Farhaan Shaikh
Nitee Shetty
Copy Editor
Insiya Morbiwala
Arvindkumar Gupta
Manu Joseph
About the Author
Ivan Idris has an MSc in Experimental Physics. His graduation thesis had a strong emphasis
on Applied Computer Science. After graduating, he worked for several companies as a Java
Developer, Data Warehouse Developer, and QA Analyst. His main professional interests are
business intelligence, big data, and cloud computing. He enjoys writing clean, testable code,
and interesting technical articles. He is the author of NumPy 1.5 Beginner's Guide. You can
find more information and a blog with a few NumPy examples at ivanidris.net.
I would like to dedicate this book to my family and friends. I would like
to take this opportunity to thank the reviewers and the team at Packt for
making this book possible. Thanks also goes to my teachers, professors,
and colleagues, who taught me about science and programming. Last but
not least, I would like to acknowledge my parents, family, and friends for
their support.
NumPy 1.5 Beginner's Guide
ISBN: 978-1-84951-530-6
Paperback: 234 pages
An action-packed guide for the easy-to-use, high
performance, Python based free open source NumPy
mathematical library using real-world examples
1. The first and only book that truly explores NumPy
practically
2. Perform high performance calculations with clean
and efficient NumPy code
3. Analyze large data sets with statistical functions
4. Execute complex linear algebra and mathematical
computations
Matplotlib for Python
Developers
ISBN: 978-1-84719-790-0
Paperback: 308 pages
Build remarkable publication-quality plots the easy way
1. Create high quality 2D plots by using Matplotlib
productively
2. Incremental introduction to Matplotlib, from the
ground up to advanced levels
3. Embed Matplotlib in GTK+, Qt, and wxWidgets
applications as well as web sites to utilize them in
Python applications
Please check www.PacktPub.com for information on our titles
Sage Beginner's Guide
ISBN: 978-1-84951-446-0
Paperback: 364 pages
Unlock the full potential of Sage for simplifying and
automating mathematical computing
1. The best way to learn Sage which is a
open source alternative to Magma, Maple,
Mathematica, and Matlab
2. Learn to use symbolic and numerical
computation to simplify your work and
produce publication-quality graphics
3. Numerically solve systems of equations, find roots,
and analyze data from experiments or simulations
R Graph Cookbook
ISBN: 978-1-84951-306-7
Paperback: 272 pages
Detailed hands-on recipes for creating the most useful
types of graphs in R—starting from the simplest versions
to more advanced applications
1. Learn to draw any type of graph or visual data
representation in R
2. Filled with practical tips and techniques for
creating any type of graph you need; not just
theoretical explanations
3. All examples are accompanied with the
corresponding graph images, so you know what
the results look like
4. Each recipe is independent and contains the
complete explanation and code to perform the
task as efficiently as possible
Please check www.PacktPub.com for information on our titles