(Press ?
for help, n
and p
for next and previous slide; usage hints)
David Wright
February 27 2021
Assortment of routines for fast operations on arrays
import numpy as np x = np.array([[1,2,3],[4,5,6]]) print(type(x)) print(x.shape) print(x)
<class 'numpy.ndarray'> (2, 3) [[1 2 3] [4 5 6]]
As an example, I’ll show how matrix multiplication can be done very easily with NumPy
import numpy as np np.set_printoptions(suppress=True) np.set_printoptions(precision=3) x = np.array([1,0]) th = np.pi / 2 y = np.array([[np.cos(th), -np.sin(th)], [np.sin(th), np.cos(th)]]) rot = np.matmul(y,x) print(rot)
[0. 1.]
Subpackage | Description |
---|---|
cluster | Clustering algorithms |
constants | Physical and mathematical constants |
fftpack | Fast Fourier Transform routines |
integrate | Integration and ordinary differential equation solvers |
interpolate | Interpolation and smoothing splines |
io | Input and Output |
linalg | Linear Algebra |
ndimage | N-dimensional image processing |
odr | Orthogonal distance regression |
Subpackage | Description |
---|---|
optimize | Optimization and root-finding routines |
signal | Signal processing |
sparse | Sparse matrices and associated routines |
spatial | Spatial data structures and algorithms |
special | Special functions |
stats | Statistical distributions and functions |
from scipy import optimize
The basic usage is as follows
import matplotlib.pyplot as plt plt.plot(#your-data)
Visit the link below to get an online instance of a Jupyter Notebook with some demos.