Learn SciPy

Scientific computing algorithms built on NumPy arrays

19 lessons · 4 hours · 4 levels · covers SciPy 1.18

SciPy is the collection of fundamental scientific algorithms for Python: statistics, optimisation, root finding, integration and ODEs, interpolation, linear algebra, sparse matrices, signal processing and special functions. It wraps decades of battle-tested Fortran and C code behind NumPy-based interfaces. Whenever you need a numerical method rather than just array arithmetic, SciPy is usually where it lives.

Before you start

SciPy builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics6 lessons · 57 min in total
2. PracticalUse it productively at work, with the usual idioms13 lessons · 2 hours in total
3. AdvancedThe less common features, performance and trade-offs16 lessons · 3 hours in total
4. ExpertInternals and the edge cases experts know19 lessons · 4 hours in total

The SciPy tree

SciPyWhat SciPy is and how it is organisedWhat SciPy is andhow it is organisedProbability distributionsProbabilitydistributionsDescriptive statisticsDescriptive statisticsHypothesis tests and p-valuesHypothesis tests andp-valuesMinimising functions with optimizeMinimising functionswith optimizeNumerical integrationNumerical integrationChoosing the right statistical testChoosing the rightstatistical testFitting models to data with curve_fitFitting models to datawith curve_fitRoot finding and solving equationsRoot finding andsolving equationsInterpolation and splinesInterpolation andsplinesSolving ODEs with solve_ivpSolving ODEs withsolve_ivpDense linear algebra with scipy.linalgDense linear algebrawith scipy.linalgSparse arrays and sparse solversSparse arrays andsparse solversThe ndarrayThe ndarrayModules and importsModules and importsAggregations and the axis argumentAggregations and theaxis argumentDefining functionsDefining functionsCreating arraysCreating arraysVectorized arithmeticVectorized arithmeticLinear algebra basicsLinear algebra basics
Essentials and Practical shown (13 of 19 lessons); the full list is below. Click a lesson to read it.

All 19 lessons, in order

Getting started

  1. What SciPy is and how it is organised · Essentials · 6 min

    Find your way around SciPy's subpackages and import them the recommended way.

Statistics

  1. Probability distributions · Essentials · 11 min

    Use scipy.stats distributions for densities, probabilities, quantiles and random samples.

  2. Descriptive statistics · Essentials · 8 min

    Summarise samples with describe, z-scores, robust statistics, skewness and correlations.

  3. Hypothesis tests and p-values · Essentials · 12 min

    Run t-tests, read p-values and confidence intervals correctly, and know what a test does not tell you.

  4. Choosing the right statistical test · Practical · 12 min

    Pick between parametric, non-parametric, categorical and correlation tests, and handle many comparisons.

  5. Bootstrap and permutation tests · Advanced · 12 min

    Get confidence intervals and p-values for any statistic by resampling instead of formulas.

Optimisation and roots

  1. Minimising functions with optimize · Essentials · 11 min

    Find the minimum of a scalar function of one or many variables with minimize_scalar and minimize.

  2. Fitting models to data with curve_fit · Practical · 11 min

    Fit a parametric model to noisy data by least squares and estimate parameter uncertainty.

  3. Root finding and solving equations · Practical · 10 min

    Solve f(x) = 0 for one or many unknowns with root_scalar, brentq and root.

  4. Constraints, gradients and global optimisation · Advanced · 14 min

    Solve bounded and constrained problems, supply gradients, and escape local minima with global methods.

Integration and interpolation

  1. Numerical integration · Essentials · 9 min

    Compute definite integrals of functions with quad and of sampled data with trapezoid and simpson.

  2. Interpolation and splines · Practical · 10 min

    Estimate values between known data points with linear, cubic-spline and shape-preserving interpolants.

  3. Solving ODEs with solve_ivp · Practical · 12 min

    Simulate systems described by differential equations, choosing solvers, tolerances and events.

Linear algebra and sparse

  1. Dense linear algebra with scipy.linalg · Practical · 11 min

    Solve systems, factorise matrices and use specialised routines that numpy.linalg lacks.

  2. Sparse arrays and sparse solvers · Practical · 12 min

    Store mostly-zero matrices efficiently and solve large sparse systems with scipy.sparse.

  3. Iterative solvers and preconditioning · Expert · 14 min

    Solve huge sparse systems and eigenproblems with Krylov methods, preconditioning and matrix-free operators.

Signals, numerics and performance

  1. Filtering, spectra and peaks · Advanced · 13 min

    Design digital filters, filter without phase shift, find peaks and estimate spectra with scipy.signal and scipy.fft.

  2. Numerical stability and special functions · Expert · 13 min

    Avoid overflow, underflow and cancellation with log-space computation, special functions and well-conditioned formulations.

  3. Performance and SciPy internals · Expert · 13 min

    Speed up SciPy-heavy code with vectorised callbacks, workers, LowLevelCallable and direct BLAS/LAPACK access.