numpy_test(): Exercises for introduction to numpy. x = [111 222 333] x[1] = 222 type(x) = len(x) = 3 np.ndim(x) = 1 np.shape(x) = (3,) np.size(x) = 3 Random vector a: [0.20497062 0.47667047 0.00088011 0.46724502 0.25808177] np.all ( 0.25 <= a ) = False np.any ( 0.75 <= a ) = False np.all ( ( 0.05 <= a ) & ( a <= 0.95 ) ) = False np.any ( ( a < 0.05 ) | ( 0.95 < a ) ) = True sinc_plot(): Consider y=sin(x)/x. ymin = nan imin = 50 xmin = 0.0 ymax = nan imax = 50 xmax = 0.0 Graphics saved as "sinc.png" Replace y(0) = 0/0 by the value 1. ymin = -0.2167568534954234 imin = 69 xmin = 4.559999999999999 ymax = 1.0 imax = 50 xmax = 0.0 Graphics saved as "sinc_marked.png" Plot a red dot wherever y(x) < 0. Graphics saved as "sinc_negative.png" [ 20 120 220 320 420] temperature_plot(): T is a 7 x 8 matrix of temperatures. T[i,j] is Celsius temperature on i-th day at j-th time. T: [[ -1 -4 -8 -9 -9 -8 -9 -8] [-12 -12 -12 -10 -5 0 0 0] [ 1 2 2 4 7 8 7 6] [ 3 3 2 2 3 5 3 1] [ 1 1 2 6 11 12 12 11] [ 8 6 5 5 8 11 9 7] [ 6 5 4 6 8 10 8 7]] plot ( h, T[day,:] ) Graphics saved as "temperature_daily.png" Using flatten() to make a single row, plot all data as one record. Graphics saved as "temperature_weekly.png" Compute minimum: Minimum each day: np.min ( T, axis = 0 ) [-12 -12 -12 -10 -9 -8 -9 -8] Minimum each hour: np.min ( T, axis = 1 ) [ -9 -12 1 1 1 5 4] Minimum over all: np.min ( T ) -12 contour_plot(): Consider z = 2x^2 - 1.05x^4 + x^6/6 + xy + y^2. Create a contour plot by sampling z(x,y) on an x y grid. Use np.linspace() to create x and y vector grids. Use np.meshgrd() to create X and Y matrix grids. Graphics saved as "contours.png"