Learning Scientific Programming with Python (2nd edition)
Chapter 6: NumPy
-
Examples
- E6.1: A "comb" Function
- E6.2: Creating a Magic Square
- E6.3: vstack and hstack
- E6.4: Checking a Sudoku grid for validity
- E6.5: argmax and argmin
- E6.6: Using NumPy's loadtxt method
- E6.7: The Stroop effect
- E6.8: Simulating radioactive decay
- E6.9: Covariance with np.cov
- E6.10: The correlation between air pressure and temperature
- E6.11: The height of liquid in a spherical tank
- E6.12: Finding a best-fit straight line
- E6.13: Creating a rotation matrix in NumPy
- E6.14: Mesh analysis of a electrical network
- E6.15: Matrix operations
- E6.16: Visualizing linear transformations
- E6.17: Fitting the Beer-Lambert law with NumPy
- E6.18: Random sampling of evenly-spaced real numbers
- E6.19: Simulating coin-tosses
- E6.20: The normal distribution
- E6.21: Modelling the distribution of $\mathrm{^{13}C}$ atoms in $\mathrm{C_{60}}$
- E6.22: The probability of cleaving DNA with EcoRI
- E6.23: Blurring an image with a two-dimensional FFT
-
Questions
- Q6.1.1: np.ndarray and np.array
- Q6.1.2: Creating a NumPy array #1
- Q6.1.3: Creating a NumPy array #2
- Q6.1.4: Changing the data type of an array
- Q6.1.5: Indexing and slicing a NumPy array
- Q6.1.6: Boolean indexing
- Q6.1.7: Using np.isclose #1
- Q6.1.8: Using np.isclose #2
- Q6.1.9: Verifying a magic square
- Q6.1.10: Determining if an array is monotonically increasing
- Q6.1.11: The dtypes of scalars and arrays
- Q6.4.1: Derivative of a polynomial
- Q6.4.2: Classifying the stationary points of a polynomial
- Q6.5.1: The unitary property of the Pauli matrices
- Q6.5.2: Fitting data to a quadratic function
- Q6.6.1: Using np.random.randint
- Q6.6.2: Using np.random.randint to sample from a set of evenly-spaced reals
- Q6.6.3: The Mega Millions lottery
- Q6.6.4: Probability of misprints
- Q6.7.1: Direct implementation of the discrete Fourier Transform
-
Problems
- P6.1.1: A structured array of whale species data
- P6.1.2: The shoelace algorithm
- P6.1.3: Gaussian functions and their derivatives
- P6.2.1: 8000 m peaks
- P6.2.2: Airport distances
- P6.2.3: Immunization rates
- P6.3.1: Analysing lottery results
- P6.3.2: Plotting a histogram with pyplot.bar
- P6.3.3: Plotting a height distribution histogram
- P6.4.1: Analysis of a nuclear explosion
- P6.4.2: Linear Regression on four data sets
- P6.4.3: The van der Waals equation of state
- P6.4.4: Saturn V first stage launch analysis
- P6.5.1: Planck units of measurement
- P6.5.2: The moment of inertia tensor
- P6.5.3: Singular value decomposition
- P6.5.4: Finding the number of integers not containing the digit 5
- P6.5.5: The Fibonacci sequence by matrix similarity transform
- P6.5.6: Conic sections
- P6.5.7: Radioactive decay
- P6.6.1: Coin-flipping simulation
- P6.6.2: Buffon's needle
- P6.6.3: A simple model for chemotaxis
- P6.6.4: Modeling meanders
- P6.7.1: Apodization
- P6.7.2: Fourier expansion of a square wave
- P6.7.3: Fourier transform of a sound file