You are previewing Mastering SciPy.
O'Reilly logo
Mastering SciPy

Book Description

Implement state-of-the-art techniques to visualize solutions to challenging problems in scientific computing, with the use of the SciPy stack

About This Book

  • Master the theory and algorithms behind numerical recipes and how they can be applied to real-world problems

  • Learn to combine the most appropriate built-in functions from the SciPy stack by understanding the connection between the sources of your problem, volume of data, or computer architecture

  • A comprehensive coverage of all the mathematical techniques needed to solve the presented topics, with a discussion of the relevant algorithms built in the SciPy stack

  • Who This Book Is For

    If you are a mathematician, engineer, or computer scientist with a proficiency in Python and familiarity with IPython, this is the book for you. Some basic knowledge of numerical methods in scientific computing would be helpful.

    What You Will Learn

  • Master relevant algorithms used in symbolic or numerical mathematics to address approximation, interpolation, differentiation, integration, root-finding, and optimization of scalar or multi-variate functions

  • Develop different algorithms and strategies to efficiently store and manipulate large matrices of data, in particular to solve systems of linear equations, or compute their eigenvalues/eigenvectors

  • Understand how to model physical problems with systems of differential equations and distinguish the factors that dictate the strategies to solve them

  • Perform statistical analysis, hypothesis test design and resolution, or data mining at a higher level, and apply them to real-life problems in the field of data analysis

  • Gain insights on the power of distances, Delaunay triangulations and Voronoi diagrams for Computational Geometry, and apply them to various engineering problems

  • Familiarize yourself with different techniques in signal/image processing, including filtering audio, images, or video to extract information, features, or remove components

  • In Detail

    The SciPy stack is a collection of open source libraries of the powerful scripting language Python, together with its interactive shells. This environment offers a cutting-edge platform for numerical computation, programming, visualization and publishing, and is used by some of the world’s leading mathematicians, scientists, and engineers. It works on any operating system that supports Python and is very easy to install, and completely free of charge! It can effectively transform into a data-processing and system-prototyping environment, directly rivalling MATLAB and Octave.

    This book goes beyond a mere description of the different built-in functions coded in the libraries from the SciPy stack. It presents you with a solid mathematical and computational background to help you identify the right tools for each problem in scientific computing and visualization. You will gain an insight into the best practices with numerical methods depending on the amount or type of data, properties of the mathematical tools employed, or computer architecture, among other factors.

    The book kicks off with a concise exploration of the basics of numerical linear algebra and graph theory for the treatment of problems that handle large data sets or matrices. In the subsequent chapters, you will delve into the depths of algorithms in symbolic algebra and numerical analysis to address modeling/simulation of various real-world problems with functions (through interpolation, approximation, or creation of systems of differential equations), and extract their representing features (zeros, extrema, integration or differentiation).

    Lastly, you will move on to advanced concepts of data analysis, image/signal processing, and computational geometry.

    Style and approach

    Packed with real-world examples, this book explores the mathematical techniques needed to solve the presented topics, and focuses on the algorithms built in the SciPy stack.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the code file.

    Table of Contents

    1. Mastering SciPy
      1. Table of Contents
      2. Mastering SciPy
      3. Credits
      4. About the Author
      5. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Numerical Linear Algebra
        1. Motivation
        2. Creation of matrices and linear operators
          1. Constructing matrices in the ndarray class
          2. Constructing matrices in the matrix class
          3. Constructing sparse matrices
          4. Linear operators
        3. Basic matrix manipulation
          1. Scalar multiplication, matrix addition, and matrix multiplication
          2. Traces and determinants
          3. Transposes and inverses
          4. Norms and condition numbers
        4. Matrix functions
        5. Matrix factorizations related to solving matrix equations
          1. Relevant factorizations
            1. Pivoted LU decomposition
            2. Cholesky decomposition
            3. QR decomposition
            4. Singular value decomposition
          2. Matrix equations
            1. Back and forward substitution
            2. Basic systems: banded matrices
            3. Basic systems: generic square matrices
            4. Least squares
              1. Normal equations
              2. QR factorization
              3. Singular value decomposition
            5. Regularized least squares
            6. Other matrix equation solvers
        6. Matrix factorizations based on eigenvalues
          1. Spectral decomposition
          2. Schur decomposition
        7. Summary
      9. 2. Interpolation and Approximation
        1. Motivation
        2. Interpolation
          1. Implementation details
          2. Univariate interpolation
            1. Nearest-neighbors interpolation
            2. Lagrange interpolation
            3. Hermite interpolation
            4. Piecewise polynomial interpolation
            5. Spline interpolation
          3. Multivariate interpolation
        3. Least squares approximation
          1. Linear least squares approximation
          2. Nonlinear least squares approximation
        4. Summary
      10. 3. Differentiation and Integration
        1. Motivation
        2. Differentiation
          1. Numerical differentiation
          2. Symbolic differentiation
          3. Automatic differentiation
        3. Integration
          1. Symbolic integration
          2. Numerical integration
            1. Functions without singularities on finite intervals
            2. Functions with singularities on bounded domains
              1. Weighted functions
              2. General functions with singularities
            3. Integration on unbounded domains
          3. Numerical multivariate integration
        4. Summary
      11. 4. Nonlinear Equations and Optimization
        1. Motivation
        2. Non-linear equations and systems
          1. Iterative methods for univariate functions
            1. Bracketing methods
            2. Secant methods
            3. Brent method
          2. Systems of nonlinear equations
            1. Simple iterative solvers
            2. The Broyden method
            3. Powell's hybrid solver
            4. Large-scale solvers
        3. Optimization
          1. Unconstrained optimization for univariate functions
          2. Constrained optimization for univariate functions
          3. Unconstrained optimization for multivariate functions
            1. The stochastic methods
            2. Deterministic algorithms that exclusively employ function evaluations
            3. The Broyden-Fletcher-Goldfarb-Shanno quasi-Newton method
            4. The conjugate gradient method
          4. Constrained optimization for multivariate functions
        4. Summary
      12. 5. Initial Value Problems for Ordinary Differential Equations
        1. Symbolic solution of differential equations
        2. Analytic approximation methods
        3. Discrete-variable methods
          1. One-step methods
          2. Two-step methods
        4. Summary
      13. 6. Computational Geometry
        1. Plane geometry
        2. Combinatorial computational geometry
          1. Static problems
            1. Convex hulls
            2. Voronoi diagrams
            3. Triangulations
            4. Shortest paths
          2. Geometric query problems
            1. Point location
            2. Nearest neighbors
            3. Range searching
          3. Dynamic problems
          4. Numerical computational geometry
          5. Bézier curves
        3. Summary
      14. 7. Descriptive Statistics
        1. Motivation
        2. Probability
          1. Symbolic setting
          2. Numerical setting
        3. Data exploration
          1. Picturing distributions with graphs
            1. Bar plots and pie charts
            2. Histograms
            3. Time plots
          2. Describing distributions with numbers and boxplots
          3. Relationship between quantitative variables
            1. Scatterplots and correlation
            2. Regression
              1. Ordinary linear regression for moderate-sized datasets
              2. Ordinary least-squares regression for large datasets
              3. Linear regression beyond ordinary least-squares
              4. Support vector machines
              5. Ensemble methods
          4. Analysis of the time series
        4. Summary
      15. 8. Inference and Data Analysis
        1. Statistical inference
          1. Estimation of parameters
            1. Frequentist approach
            2. Bayesian approach
            3. Likelihood approach
          2. Interval estimation
            1. Frequentist approach
            2. Bayesian approach
            3. Likelihood approach
        2. Data mining and machine learning
          1. Classification
            1. Support vector classification
            2. Trees
            3. Naive Bayes
            4. Nearest neighbors
          2. Dimensionality reduction
            1. Principal component analysis
            2. Isometric mappings
            3. Spectral embedding
            4. Locally linear embedding
          3. Clustering
            1. MeanShift
            2. Gaussian mixture models
            3. Kmeans
            4. Spectral clustering
        3. Summary
      16. 9. Mathematical Imaging
        1. Digital images
          1. Binary
          2. Gray-scale
        2. Color
          1. Alpha channels
        3. High-level operations on digital images
          1. Object measurements
          2. Mathematical morphology
          3. Smoothing filters
          4. Multivariate calculus
          5. Statistical filters
          6. Fourier analysis
          7. Wavelet decompositions
        4. Image compression
          1. Lossless compression
          2. Lossy compression
        5. Image editing
          1. Transformations of the domain
            1. Rescale and resize
            2. Swirl
            3. Geometric transformations
          2. Intensity adjustment
            1. Histogram equalization
            2. Intensity clipping/resizing
            3. Contrast enhancement
          3. Image restoration
            1. Noise reduction
            2. Sharpening and blurring
          4. Inpainting
        6. Image analysis
          1. Image structure
          2. Object recognition
            1. Edge detection
            2. Line, circle, and ellipse detection
            3. Blob detection
            4. Corner detection
            5. Beyond geometric entities
        7. Summary
      17. Index