Skip to content
Tutorials Center
My learning

Topics

SciPy Tutorial

Learn SciPy from optimisation and integration to statistics, signal processing, sparse matrices, spatial algorithms and real projects. 38 lessons with live examples, quizzes and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is SciPy? Learn what SciPy is, how it differs from NumPy and pandas, which submodules it offers, and when to reach for it. Includes live examples you can run.
  2. 2 NumPy Refresher for SciPy Review the NumPy skills SciPy relies on: array shape and dtype, slicing, broadcasting, vectorization, linspace, seeded random numbers and basic plots.
  3. 3 Constants, Units and Conventions Use scipy.constants for physical constants and unit conversions, and learn SciPy's array conventions, result objects like OptimizeResult and how to read the docs.
  4. 4 Reading and Writing Data Files Use scipy.io to read and write MATLAB .mat files, WAV audio and Matrix Market data, and choose between npy, npz, text and sparse formats for your arrays.

Linear Algebra

  1. 5 Matrices, Solving Systems and Inverses Learn scipy.linalg basics: solve linear systems, compute norms and determinants, understand why you should not invert matrices, and read the condition number.
  2. 6 LU, QR, Cholesky and Schur Decompositions Learn the LU, QR, Cholesky and Schur matrix decompositions in scipy.linalg, how to reuse a factorization for many right-hand sides, and which one to choose.
  3. 7 Eigenvalues and Singular Values Compute eigenvalues with eig and eigh, factor matrices with svd, build low-rank image approximations, run PCA from scratch and use the matrix exponential expm.
  4. 8 Least Squares and Pseudo-inverses Solve overdetermined systems with scipy.linalg.lstsq and pinv, fit lines and parabolas, avoid the normal equations trap and use Toeplitz and circulant matrices.

Optimization

  1. 9 Scalar Minimization and Root Finding Find the minimum or the zero of a one-variable function with minimize_scalar, brentq, bisect, newton and root_scalar. Learn brackets and read convergence info.
  2. 10 Minimizing Functions of Many Variables Use scipy.optimize.minimize on functions of many variables. Compare BFGS, Nelder-Mead and L-BFGS-B, supply gradients, add bounds and callbacks, read the result.
  3. 11 Constraints, Bounds and Global Optimization Add equality and inequality constraints with SLSQP and trust-constr, then escape local minima using differential_evolution, dual_annealing, basinhopping and shgo.
  4. 12 Curve Fitting and Least Squares Fit nonlinear models to noisy data with curve_fit and least_squares. Learn residuals, parameter errors from the covariance matrix, weights and robust loss.
  5. 13 Linear and Integer Programming Solve production planning, diet and knapsack problems with scipy.optimize.linprog (HiGHS) and milp, read status and shadow prices, and assign tasks optimally.

Integration and Differential Equations

  1. 14 Numerical Integration Compute definite integrals in SciPy with quad, dblquad and nquad, handle infinite limits and spikes, and integrate sampled data with trapezoid and simpson.
  2. 15 Solving ODEs with solve_ivp Solve initial value problems in Python with scipy.integrate.solve_ivp: choose RK45 or DOP853, set tolerances, sample with t_eval, use events and dense output.
  3. 16 Stiff Systems and Higher-Order ODEs Learn what stiffness means and when to use Radau, BDF or LSODA instead of RK45. Convert higher-order ODEs, model Lotka-Volterra and Lorenz, and use solve_bvp.

Interpolation and Smoothing

  1. 17 One-Dimensional Interpolation Learn 1D interpolation in SciPy: np.interp, CubicSpline, PchipInterpolator and Akima, boundary conditions, why extrapolation fails, and the Runge phenomenon.
  2. 18 Multidimensional and Scattered-Data Interpolation Interpolate in 2D and beyond with RegularGridInterpolator, griddata and RBFInterpolator, smooth noisy data with splines, and resample images in SciPy.

Statistics

  1. 19 Distributions and Descriptive Statistics Use scipy.stats distribution objects: pdf, cdf, ppf, rvs, loc and scale, frozen distributions, describe and summary statistics, and fit a distribution to data.
  2. 20 Hypothesis Testing Run t-tests, Mann-Whitney, chi-square, ANOVA and normality tests with scipy.stats, read p-values and effect sizes, correct for multiple tests and use permutation_test.
  3. 21 Correlation, Regression and Bootstrap Measure relationships with pearsonr and spearmanr, fit lines with linregress, build confidence intervals with the bootstrap, run Monte Carlo simulations and use gaussian_kde.

Signal Processing

  1. 22 The Fast Fourier Transform Use scipy.fft to find the frequencies hidden in a signal: rfft and rfftfreq, amplitude scaling, aliasing, windowing, zero padding, the DCT and why the FFT is fast.
  2. 23 Filter Design and Filtering Signals Design and apply digital filters with scipy.signal: Butterworth IIR filters, sosfilt and filtfilt, FIR filters with firwin, freqz responses, convolution and median filters.
  3. 24 Spectrograms, Peaks and Resampling Estimate power spectra with welch, track changing frequencies with spectrogram, detect peaks with prominence, resample, smooth with savgol_filter and find delays by cross-correlation.

Sparse, Spatial and Image Data

  1. 25 Sparse Matrices Store mostly-zero data efficiently with scipy.sparse: COO, CSR, CSC and LIL formats, sparse arrays versus matrices, conversions, memory savings, products and common pitfalls.
  2. 26 Sparse Linear Algebra and Graph Algorithms Solve huge sparse systems with spsolve and cg, find a few eigenvalues with eigsh and svds, and run shortest paths, components and spanning trees with csgraph.
  3. 27 Spatial Algorithms Find nearest neighbors with KDTree, build distance matrices with cdist, compute hulls, Delaunay and Voronoi diagrams, rotate in 3D and cluster hierarchically.
  4. 28 Image Processing with scipy.ndimage Smooth, sharpen and find edges with scipy.ndimage, label and measure objects, clean masks with morphology, and rotate or zoom images, all on a synthetic image.
  5. 29 Special Functions and Clustering Use scipy.special for gamma, beta, erf, Bessel, comb, expit and logsumexp, avoid overflow with stable formulas, and cluster data with kmeans and vq.

Projects

  1. 30 Project: Denoise and Analyze a Sensor Signal Build a signal pipeline with SciPy: simulate a noisy sensor, inspect its FFT spectrum, filter it, detect peaks and report the result with plots.
  2. 31 Project: Fit an Epidemic Model to Data Simulate an SIR epidemic with solve_ivp, fit its parameters with least_squares, quantify the uncertainty and forecast the outbreak with a confidence band.
  3. 32 Project: Analyze an A/B Test Analyze a simulated A/B test with scipy.stats. Run proportion tests, build bootstrap confidence intervals, estimate power and write a decision memo.
  4. 33 Project: Simulate Heat Diffusion with Sparse Solvers Simulate 2D heat diffusion with a sparse finite-difference Laplacian. Compare explicit and implicit time stepping, use splu, and draw animation frames.

Practice and Review

  1. 34 Performance, Accuracy and Common Pitfalls Make numerical Python fast and trustworthy. Vectorize loops, pick dtypes, understand floating-point error and tolerances, and know when SciPy is not enough.
  2. 35 Testing Numerical Code Test numerical Python reliably. Use np.testing.assert_allclose with sensible tolerances, known-solution tests, fixed seeds and property checks.
  3. 36 Exercises with Solutions Twelve SciPy practice problems on optimization, integration, ODEs, statistics, signals and sparse matrices. Each one has a runnable, checked solution.
  4. 37 Interview Questions Twelve SciPy and numerical computing interview questions on conditioning, stiffness, p-values, local minima and sparse formats, with short runnable answers.
  5. 38 SciPy Cheat Sheet A one-page SciPy cheat sheet to see which function to use for linear algebra, optimization, integration, statistics, signals, sparse data and more, with live examples.