Popular recipes tagged "linspace"http://code.activestate.com/recipes/tags/linspace/2015-01-12T22:16:37-08:00ActiveState Code RecipesEqually-spaced numbers (linspace) (Python) 2015-01-12T22:16:37-08:00Andrew Barnerthttp://code.activestate.com/recipes/users/4184316/http://code.activestate.com/recipes/579000-equally-spaced-numbers-linspace/ <p style="color: grey"> Python recipe 579000 by <a href="/recipes/users/4184316/">Andrew Barnert</a> (<a href="/recipes/tags/float/">float</a>, <a href="/recipes/tags/linspace/">linspace</a>, <a href="/recipes/tags/range/">range</a>, <a href="/recipes/tags/spread/">spread</a>). </p> <p>An equivalent of <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html"><code>numpy.linspace</code></a>, but as a pure-Python lazy sequence.</p> <p>Like NumPy's <code>linspace</code>, but unlike the <a href="http://code.activestate.com/recipes/577068/"><code>spread</code></a> and <a href="http://code.activestate.com/recipes/577068/"><code>frange</code></a> recipes listed here, the <code>num</code> argument specifies the number of values, not the number of intervals, and the range is closed, not half-open.</p> <p>Although this is primarily designed for floats, it will work for <code>Fraction</code>, <code>Decimal</code>, NumPy arrays (although this would be silly) and even <code>datetime</code> values.</p> <p>This recipe can also serve as an example for creating lazy sequences.</p> <p>See the discussion below for caveats.</p>