December 2017
Intermediate to advanced
386 pages
10h 42m
English
There are two NumPy functions that create arrays with equally spaced elements: arange() and linspace(). The arange() function, which stands for array range, has an interface similar to the built-in Python range() function, except that the arguments can be floats, as shown in the following example:
x = np.arange(1.1, 1.9, 0.2)
This generates an array with elements between 1.1 and 1.9, with increments of 0.2, resulting in the array as follows:
array([ 1.1, 1.3, 1.5, 1.7])
Notice that the right endpoint is not included, that is, arange() uses the same convention as range(). As in the built-in Python range() function, the increment can be omitted, and is then assumed to be equal to 1, as demonstrated ...
Read now
Unlock full access