NumPy in practice
Linear algebra with @ and np.linalg, random numbers and simulation with seeded generators, and images as arrays.
About 6 hours of study
Learning objectives
- Multiply matrices and solve linear systems
- Run reproducible simulations
- Process images with slicing, masks and clipping
Lessons
- 1
Linear algebra with NumPy Advanced
Vectors and matrices in NumPy: dot products, the @ operator for matrix multiplication and its shape rule, the identity, the determinant and inverse, and solving systems of equations with np.linalg.solve.
- 2
Random numbers and simulation Intermediate
NumPy's random generator: default_rng and seeds for reproducible results, integers, random, normal and choice, shuffling and permutations, how a pseudo-random generator works, and Monte Carlo estimates with their error.
- 3
NumPy in practice: images as arrays Advanced
Putting NumPy to work on images: pixels as uint8 arrays with shape (height, width) or (height, width, 3), cropping and flipping with slices, brightness changes with clipping and the uint8 overflow trap, masks and simple filters.
Module practice
- NumPy: The dot productEasy
- NumPy: Matrix multiplicationMedium
- NumPy: Solve two equationsHard
- NumPy: A linear congruential generatorEasy
- NumPy: A Fisher–Yates shuffleMedium
- NumPy: Estimate π from random pointsHard
- NumPy: Flip an imageEasy
- NumPy: Brighten without overflowMedium
- NumPy: Crop and downsampleHard