linspace Generate an ordered list , The key lies in the data range and the number of data .
linspace Used to create a one-dimensional array of arithmetic sequences , Three parameters are commonly used :
The code is as follows :
Example 1:
np.linspace(0,10,5)
As can be seen from the results , take 0-10 The closed interval is divided into 5 Data points ,4 A data range
Example 2:
np.linspace(0,10,5,endpoint=False)
It can be seen from the results , take 0-10 The interval is divided into 6 Data points ,5 Intervals . Does not contain the right endpoint , Can't get 10.