How to create an array of linearly spaced points using numpy?
<p>I am trying to create an array of equally spaced points using numpy, as below:</p>

<pre><code>array([ 0.        ,  0.05263158,  0.10526316,  0.15789474,  0.21052632,
    0.26315789,  0.31578947,  0.36842105,  0.42105263,  0.47368421,
    0.52631579,  0.57894737,  0.63157895,  0.68421053,  0.73684211,
    0.78947368,  0.84210526,  0.89473684,  0.94736842,  1.        ])
</code></pre>

<p>This array is 20 points between 0 and 1, all with the same amount of space between them. </p>

<p>Looking at the documentation for <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.array.html" rel="nofollow"><code>numpy.array</code></a>, however, I don't see a way to do this by passing in an extra parameter. Is this possible to do as a quick-and-easy one-liner?</p>

<p>Use linspace.</p>

<pre><code>np.linspace(0, 1, 20)
</code></pre>

<p><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html" rel="nofollow">http://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html</a></p>

python arrays numpy