## About This Book

- Perform high performance calculations with clean and efficient NumPy code.
- Analyze large data sets with statistical functions
- Execute complex linear algebra and mathematical computations

Register for an account and access leading-edge content on emerging technologies.

Build fast, compact, and dynamic web applications with a high performance UI to deliver a spellbinding user experience with ReactJS

$19.00

RRP $94.99

Application Flow With Generators

If you're looking to fall back to using events to enforce the concept of a workflow, discover what Generators can do for you to help your applications business logic

Packt Publishing

Added to Cart

...and more

You don't have anything in your cart right now.

Subtotal

0.00

**Free shipping** on print orders for US, UK, Europe and selected Asian countries

An action packed guide using real world examples of the easy to use, high performance, free open source NumPy mathematical library.

Beginner's Guide

Ivan Idris

An action packed guide using real world examples of the easy to use, high performance, free open source NumPy mathematical library.

$26.99

$44.99

RRP $26.99

RRP $44.99

$12.99 p/month

Get Access

Enjoy full and instant access to over 3000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

ISBN 139781782166085

Paperback310 pages

- Perform high performance calculations with clean and efficient NumPy code.
- Analyze large data sets with statistical functions
- Execute complex linear algebra and mathematical computations

If you are a programmer, scientist, or engineer who has basic Python knowledge and would like to be able to do numerical computations with Python, this book is for you. No prior knowledge of NumPy is required.

Chapter 1: NumPy Quick Start

Python

Time for action – installing Python on different operating systems

Windows

Time for action – installing NumPy, Matplotlib, SciPy, and IPython on Windows

Linux

Time for action – installing NumPy, Matplotlib, SciPy, and IPython on Linux

Mac OS X

Time for action – installing NumPy, Matplotlib, and SciPy on Mac OS X

Time for action – installing NumPy, SciPy, Matplotlib, and IPython with MacPorts or Fink

Building from source

Arrays

Time for action – adding vectors

IPython—an interactive shell

Online resources and help

Summary

Chapter 2: Beginning with NumPy Fundamentals

NumPy array object

Time for action – creating a multidimensional array

Time for action – creating a record data type

One-dimensional slicing and indexing

Time for action – slicing and indexing multidimensional arrays

Time for action – manipulating array shapes

Time for action – stacking arrays

Time for action – splitting arrays

Time for action – converting arrays

Summary

Chapter 3: Get in Terms with Commonly Used Functions

File I/O

Time for action – reading and writing files

CSV files

Time for action – loading from CSV files

Volume-weighted average price

Time for action – calculating volume-weighted average price

Value range

Time for action – finding highest and lowest values

Statistics

Time for action – doing simple statistics

Stock returns

Time for action – analyzing stock returns

Dates

Time for action – dealing with dates

Weekly summary

Time for action – summarizing data

Average true range

Time for action – calculating the average true range

Simple moving average

Time for action – computing the simple moving average

Exponential moving average

Time for action – calculating the exponential moving average

Bollinger bands

Time for action – enveloping with Bollinger bands

Linear model

Time for action – predicting price with a linear model

Trend lines

Time for action – drawing trend lines

Methods of ndarray

Time for action – clipping and compressing arrays

Factorial

Time for action – calculating the factorial

Summary

Chapter 4: Convenience Functions for Your Convenience

Correlation

Time for action – trading correlated pairs

Polynomials

Time for action – fitting to polynomials

On-balance volume

Time for action – balancing volume

Simulation

Time for action – avoiding loops with vectorize

Smoothing

Time for action – smoothing with the hanning function

Summary

Chapter 5: Working with Matrices and ufuncs

Matrices

Time for action – creating matrices

Creating a matrix from other matrices

Time for action – creating a matrix from other matrices

Universal functions

Time for action – creating universal function

Universal function methods

Time for action – applying the ufunc methods on add

Arithmetic functions

Time for action – dividing arrays

Time for action – computing the modulo

Fibonacci numbers

Time for action – computing Fibonacci numbers

Lissajous curves

Time for action – drawing Lissajous curves

Square waves

Time for action – drawing a square wave

Sawtooth and triangle waves

Time for action – drawing sawtooth and triangle waves

Bitwise and comparison functions

Time for action – twiddling bits

Summary

Chapter 6: Move Further with NumPy Modules

Linear algebra

Time for action – inverting matrices

Solving linear systems

Time for action – solving a linear system

Finding eigenvalues and eigenvectors

Time for action – determining eigenvalues and eigenvectors

Singular value decomposition

Time for action – decomposing a matrix

Pseudoinverse

Time for action – computing the pseudo inverse of a matrix

Determinants

Time for action – calculating the determinant of a matrix

Fast Fourier transform

Time for action – calculating the Fourier transform

Shifting

Time for action – shifting frequencies

Random numbers

Time for action – gambling with the binomial

Hypergeometric distribution

Time for action – simulating a game show

Continuous distributions

Time for action – drawing a normal distribution

Lognormal distribution

Time for action – drawing the lognormal distribution

Summary

Chapter 7: Peeking into Special Routines

Sorting

Time for action – sorting lexically

Complex numbers

Time for action – sorting complex numbers

Searching

Time for action – using searchsorted

Array elements' extraction

Time for action – extracting elements from an array

Financial functions

Time for action – determining future value

Present value

Time for action – getting the present value

Net present value

Time for action – calculating the net present value

Internal rate of return

Time for action – determining the internal rate of return

Periodic payments

Time for action – calculating the periodic payments

Number of payments

Time for action – determining the number of periodic payments

Interest rate

Time for action – figuring out the rate

Window functions

Time for action – plotting the Bartlett window

Blackman window

Time for action – smoothing stock prices with the Blackman window

Hamming window

Time for action – plotting the Hamming window

Kaiser window

Time for action – plotting the Kaiser window

Special mathematical functions

Time for action – plotting the modified Bessel function

sinc

Time for action – plotting the sinc function

Summary

Chapter 8: Assure Quality with Testing

Assert functions

Time for action – asserting almost equal

Approximately equal arrays

Time for action – asserting approximately equal

Almost equal arrays

Time for action – asserting arrays almost equal

Equal arrays

Time for action – comparing arrays

Ordering arrays

Time for action – checking the array order

Objects comparison

Time for action – comparing objects

String comparison

Time for action – comparing strings

Floating point comparisons

Time for action – comparing with assert_array_almost_equal_nulp

Comparison of floats with more ULPs

Time for action – comparing using maxulp of 2

Unit tests

Time for action – writing a unit test

Nose tests decorators

Time for action – decorating tests

Docstrings

Time for action – executing doctests

Summary

Chapter 9: Plotting with Matplotlib

Simple plots

Time for action – plotting a polynomial function

Plot format string

Time for action – plotting a polynomial and its derivative

Subplots

Time for action – plotting a polynomial and its derivatives

Finance

Time for action – plotting a year’s worth of stock quotes

Histograms

Time for action – charting stock price distributions

Logarithmic plots

Time for action – plotting stock volume

Scatter plots

Time for action – plotting price and volume returns with scatter plot

Fill between

Time for action – shading plot regions based on a condition

Legend and annotations

Time for action – using legend and annotations

Three dimensional plots

Time for action – plotting in three dimensions

Contour plots

Time for action – drawing a filled contour plot

Animation

Time for action – animating plots

Summary

Chapter 10: When NumPy is Not Enough – SciPy and Beyond

MATLAB and Octave

Time for action – saving and loading a .mat file

Statistics

Time for action – analyzing random values

Samples’ comparison and SciKits

Time for action – comparing stock log returns

Signal processing

Time for action – detecting a trend in QQQ

Fourier analysis

Time for action – filtering a detrended signal

Mathematical optimization

Time for action – fitting to a sine

Numerical integration

Time for action – calculating the Gaussian integral

Interpolation

Time for action – interpolating in one dimension

Image processing

Time for action – manipulating Lena

Audio processing

Time for action – replaying audio clips

Summary

Chapter 11: Playing with Pygame

Pygame

Time for action – installing Pygame

Hello World

Time for action – creating a simple game

Animation

Time for action – animating objects with NumPy and Pygame

Matplotlib

Time for action – using Matplotlib in Pygame

Surface pixels

Time for action – accessing surface pixel data with NumPy

Artificial intelligence

Time for action – clustering points

OpenGL and Pygame

Time for action – drawing the Sierpinski gasket

Simulation game with PyGame

Time for action – simulating life

Summary

- Install NumPy
- NumPy arrays
- Universal functions
- NumPy matrices
- NumPy modules
- Plot with Matplotlib
- Test NumPy code
- Relation to SciPy

NumPy is an extension to, and the fundamental package for scientific computing with Python. In today's world of science and technology, it is all about speed and flexibility. When it comes to scientific computing, NumPy is on the top of the list.

NumPy Beginner's Guide will teach you about NumPy, a leading scientific computing library. NumPy replaces a lot of the functionality of Matlab and Mathematica, but in contrast to those products, is free and open source.

Write readable, efficient, and fast code, which is as close to the language of mathematics as is currently possible with the cutting edge open source NumPy software library. Learn all the ins and outs of NumPy that requires you to know basic Python only. Save thousands of dollars on expensive software, while keeping all the flexibility and power of your favourite programming language.You will learn about installing and using NumPy and related concepts. At the end of the book we will explore some related scientific computing projects. This book will give you a solid foundation in NumPy arrays and universal functions. Through examples, you will also learn about plotting with Matplotlib and the related SciPy project. NumPy Beginner's Guide will help you be productive with NumPy and have you writing clean and fast code in no time at all.

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. Ivan enjoys writing clean, testable code and interesting technical articles. He is the author of NumPy Beginner's Guide, NumPy Cookbook, Learning NumPy Array, and Python Data Analysis. You can find more information about him and a blog with a few examples of NumPy at http://ivanidris.net/wordpress/.

Chapter 1: NumPy Quick Start

Python

Time for action – installing Python on different operating systems

Windows

Time for action – installing NumPy, Matplotlib, SciPy, and IPython on Windows

Linux

Time for action – installing NumPy, Matplotlib, SciPy, and IPython on Linux

Mac OS X

Time for action – installing NumPy, Matplotlib, and SciPy on Mac OS X

Time for action – installing NumPy, SciPy, Matplotlib, and IPython with MacPorts or Fink

Building from source

Arrays

Time for action – adding vectors

IPython—an interactive shell

Online resources and help

Summary

Chapter 2: Beginning with NumPy Fundamentals

NumPy array object

Time for action – creating a multidimensional array

Time for action – creating a record data type

One-dimensional slicing and indexing

Time for action – slicing and indexing multidimensional arrays

Time for action – manipulating array shapes

Time for action – stacking arrays

Time for action – splitting arrays

Time for action – converting arrays

Summary

Chapter 3: Get in Terms with Commonly Used Functions

File I/O

Time for action – reading and writing files

CSV files

Time for action – loading from CSV files

Volume-weighted average price

Time for action – calculating volume-weighted average price

Value range

Time for action – finding highest and lowest values

Statistics

Time for action – doing simple statistics

Stock returns

Time for action – analyzing stock returns

Dates

Time for action – dealing with dates

Weekly summary

Time for action – summarizing data

Average true range

Time for action – calculating the average true range

Simple moving average

Time for action – computing the simple moving average

Exponential moving average

Time for action – calculating the exponential moving average

Bollinger bands

Time for action – enveloping with Bollinger bands

Linear model

Time for action – predicting price with a linear model

Trend lines

Time for action – drawing trend lines

Methods of ndarray

Time for action – clipping and compressing arrays

Factorial

Time for action – calculating the factorial

Summary

Chapter 4: Convenience Functions for Your Convenience

Correlation

Time for action – trading correlated pairs

Polynomials

Time for action – fitting to polynomials

On-balance volume

Time for action – balancing volume

Simulation

Time for action – avoiding loops with vectorize

Smoothing

Time for action – smoothing with the hanning function

Summary

Chapter 5: Working with Matrices and ufuncs

Matrices

Time for action – creating matrices

Creating a matrix from other matrices

Time for action – creating a matrix from other matrices

Universal functions

Time for action – creating universal function

Universal function methods

Time for action – applying the ufunc methods on add

Arithmetic functions

Time for action – dividing arrays

Time for action – computing the modulo

Fibonacci numbers

Time for action – computing Fibonacci numbers

Lissajous curves

Time for action – drawing Lissajous curves

Square waves

Time for action – drawing a square wave

Sawtooth and triangle waves

Time for action – drawing sawtooth and triangle waves

Bitwise and comparison functions

Time for action – twiddling bits

Summary

Chapter 6: Move Further with NumPy Modules

Linear algebra

Time for action – inverting matrices

Solving linear systems

Time for action – solving a linear system

Finding eigenvalues and eigenvectors

Time for action – determining eigenvalues and eigenvectors

Singular value decomposition

Time for action – decomposing a matrix

Pseudoinverse

Time for action – computing the pseudo inverse of a matrix

Determinants

Time for action – calculating the determinant of a matrix

Fast Fourier transform

Time for action – calculating the Fourier transform

Shifting

Time for action – shifting frequencies

Random numbers

Time for action – gambling with the binomial

Hypergeometric distribution

Time for action – simulating a game show

Continuous distributions

Time for action – drawing a normal distribution

Lognormal distribution

Time for action – drawing the lognormal distribution

Summary

Chapter 7: Peeking into Special Routines

Sorting

Time for action – sorting lexically

Complex numbers

Time for action – sorting complex numbers

Searching

Time for action – using searchsorted

Array elements' extraction

Time for action – extracting elements from an array

Financial functions

Time for action – determining future value

Present value

Time for action – getting the present value

Net present value

Time for action – calculating the net present value

Internal rate of return

Time for action – determining the internal rate of return

Periodic payments

Time for action – calculating the periodic payments

Number of payments

Time for action – determining the number of periodic payments

Interest rate

Time for action – figuring out the rate

Window functions

Time for action – plotting the Bartlett window

Blackman window

Time for action – smoothing stock prices with the Blackman window

Hamming window

Time for action – plotting the Hamming window

Kaiser window

Time for action – plotting the Kaiser window

Special mathematical functions

Time for action – plotting the modified Bessel function

sinc

Time for action – plotting the sinc function

Summary

Chapter 8: Assure Quality with Testing

Assert functions

Time for action – asserting almost equal

Approximately equal arrays

Time for action – asserting approximately equal

Almost equal arrays

Time for action – asserting arrays almost equal

Equal arrays

Time for action – comparing arrays

Ordering arrays

Time for action – checking the array order

Objects comparison

Time for action – comparing objects

String comparison

Time for action – comparing strings

Floating point comparisons

Time for action – comparing with assert_array_almost_equal_nulp

Comparison of floats with more ULPs

Time for action – comparing using maxulp of 2

Unit tests

Time for action – writing a unit test

Nose tests decorators

Time for action – decorating tests

Docstrings

Time for action – executing doctests

Summary

Chapter 9: Plotting with Matplotlib

Simple plots

Time for action – plotting a polynomial function

Plot format string

Time for action – plotting a polynomial and its derivative

Subplots

Time for action – plotting a polynomial and its derivatives

Finance

Time for action – plotting a year’s worth of stock quotes

Histograms

Time for action – charting stock price distributions

Logarithmic plots

Time for action – plotting stock volume

Scatter plots

Time for action – plotting price and volume returns with scatter plot

Fill between

Time for action – shading plot regions based on a condition

Legend and annotations

Time for action – using legend and annotations

Three dimensional plots

Time for action – plotting in three dimensions

Contour plots

Time for action – drawing a filled contour plot

Animation

Time for action – animating plots

Summary

Chapter 10: When NumPy is Not Enough – SciPy and Beyond

MATLAB and Octave

Time for action – saving and loading a .mat file

Statistics

Time for action – analyzing random values

Samples’ comparison and SciKits

Time for action – comparing stock log returns

Signal processing

Time for action – detecting a trend in QQQ

Fourier analysis

Time for action – filtering a detrended signal

Mathematical optimization

Time for action – fitting to a sine

Numerical integration

Time for action – calculating the Gaussian integral

Interpolation

Time for action – interpolating in one dimension

Image processing

Time for action – manipulating Lena

Audio processing

Time for action – replaying audio clips

Summary

Chapter 11: Playing with Pygame

Pygame

Time for action – installing Pygame

Hello World

Time for action – creating a simple game

Animation

Time for action – animating objects with NumPy and Pygame

Matplotlib

Time for action – using Matplotlib in Pygame

Surface pixels

Time for action – accessing surface pixel data with NumPy

Artificial intelligence

Time for action – clustering points

OpenGL and Pygame

Time for action – drawing the Sierpinski gasket

Simulation game with PyGame

Time for action – simulating life

Summary

ISBN 139781782166085

Paperback310 pages

Read More

Learning NumPy Array

$ 16.99

NumPy: Beginner's Guide - Third Edition

$ 35.99

NumPy Cookbook - Second Edition

$ 35.99

Learning IPython for Interactive Computing and Data Visualization

$ 17.99

Learning NumPy Array

$ 16.99

We understand your time is important. Uniquely amongst the major publishers, we seek to develop and publish the broadest range of learning and information products on each technology. Every Packt product delivers a specific learning pathway, broadly defined by the Series type. This structured approach enables you to select the pathway which best suits your knowledge level, learning style and task objectives.

As a new user, these step-by-step tutorial guides will give you all the practical skills necessary to become competent and efficient.

Friendly, informal tutorials that provide a practical introduction using examples, activities, and challenges.

Fast paced, concentrated introductions showing the quickest way to put the tool to work in the real world.

A collection of practical self-contained recipes that all users of the technology will find useful for building more powerful and reliable systems.

Guides you through the most common types of project you'll encounter, giving you end-to-end guidance on how to build your specific solution quickly and reliably.

Take your skills to the next level with advanced tutorials that will give you confidence to master the tool's most powerful features.

Accessible to readers adopting the topic, these titles get you into the tool or technology so that you can become an effective user.

Building on core skills you already have, these titles share solutions and expertise so you become a highly productive power user.