title: Select N evenly spaced out elements in array, including first and last
body: <p>I have an array of arbitrary length, and I want to select N elements of it, evenly spaced out (approximately, as N may be even, array length may be prime, etc) that includes the very first <code>arr[0]</code> element and the very last <code>arr[len-1]</code> element.</p>
  <p>Example:</p>
  <pre><code>&gt;&gt;&gt; arr = np.arange(17)
  &gt;&gt;&gt; arr
  array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16])
  </code></pre>
  <p>Then I want to make a function like the following to grab <code>numElems</code> evenly spaced out within the array, which must include the first and last element:</p>
  <pre><code>GetSpacedElements(numElems = 4)
  &gt;&gt;&gt; returns 0, 5, 11, 16
  </code></pre>
  <p>Does this make sense?</p>
  <p>I've tried <code>arr[0:len:numElems]</code> (i.e. using the array <code>start:stop:skip</code> notation) and some slight variations, but I'm not getting what I'm looking for here:</p>
  <pre><code>&gt;&gt;&gt; arr[0:len:numElems]
  array([ 0,  4,  8, 12, 16])
  </code></pre>
  <p>or</p>
  <pre><code>&gt;&gt;&gt; arr[0:len:numElems+1]
  array([ 0,  5, 10, 15])
  </code></pre>
  <p>I don't care exactly what the middle elements are, as long as they're spaced evenly apart, off by an index of 1 let's say. But getting the right number of elements, including the index zero and last index, are critical.</p>