spiketools.spatial.distance.compute_distances

spiketools.spatial.distance.compute_distances(position)[source]

Compute distances across a sequence of positions.

Parameters:
position1d or 2d array

Position values.

Returns:
distances1d array

Vector of distances between positions.

Examples

Compute distances across a sequence of 1d positions:

>>> position = np.array([1., 2., 4., 5.])
>>> compute_distances(position)
array([1., 2., 1.])

Compute distances across a sequence of 2d positions:

>>> position = np.array([[1, 2, 2, 3],
...                      [1, 1, 2, 3]])
>>> compute_distances(position)
array([1.        , 1.        , 1.41421356])