CS 472 Module 2: Simple Numpy Tunes Part 1
Module content developed by Professor Tralie. Module engine developed by Professor Tralie and Professor Mongan.
Please watch the video below, and click the Next
button to continue when you're finished
linspace and arange¶
In [15]:
import numpy as np
import matplotlib.pyplot as plt
import IPython.display as ipd
In [10]:
## Generate 100 samples, equally spaced, starting at 0 and ending at 1
x = np.arange(100)/99
plt.plot(x)
Out[10]:
In [11]:
print(x[0])
print(x[-1])
In [13]:
x = np.linspace(0, 1, 100)
plt.plot(x)
print(x[0])
print(x[-1])
In [14]:
## Ex) Take 32 equally spaced samples between -np.pi and np.pi
x = np.linspace(-np.pi, np.pi, 32)
plt.stem(x)
Out[14]:
In [ ]: