All courses › Intermediate Programming › linspace and arange
linspace and arange
np.linspace(a, b, n) gives evenly spaced points from up to and including — both endpoints are included. np.arange(a, b, s) works like range, but returns an array and also accepts decimal steps.
spacing between points:
Symbols
| start and end value | ||
| number of points |
Example
np.linspace(0, 1, 5) gives [0, 0.25, 0.5, 0.75, 1], spacing .
linspace takes the number of points, arange takes the step size — easy to mix up.