spiketools.spatial.distance.compute_cumulative_distances¶
- spiketools.spatial.distance.compute_cumulative_distances(position, align_output=True)[source]¶
Compute cumulative distance across a sequence of positions.
- Parameters:
- position1d or 2d array
Position values.
- align_outputbool, optional, default: True
If True, aligns the output with the sampling of the input, to match length. To do so, value of 0 is prepended to the output array.
- Returns:
- 1d array
Cumulative distances.
Examples
Compute cumulative distances across a sequence of 1d positions:
>>> position = np.array([1., 2., 4., 5.]) >>> compute_cumulative_distances(position) array([0., 1., 3., 4.])
Compute cumulative distances across a sequence of 2d positions:
>>> position = np.array([[1, 2, 2, 3], ... [1, 1, 2, 3]]) >>> compute_cumulative_distances(position) array([0. , 1. , 2. , 3.41421356])