victor_purpura_distance

victor_purpura_distance#

class braintools.metric.victor_purpura_distance(spike_times_1, spike_times_2, cost_factor=1.0)#

Calculate Victor-Purpura distance between two spike trains.

The Victor-Purpura distance quantifies the dissimilarity between two spike trains by computing the minimum cost to transform one spike train into another through spike insertions, deletions, and temporal shifts.

The distance is computed as:

\[D_{VP} = \min \sum_{ops} c_{op}\]

where the cost of moving a spike by time \(\Delta t\) is \(q|\Delta t|\), insertion/deletion costs are 1, and \(q\) is the cost factor.

Parameters:
  • spike_times_1 (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – First spike train as array of spike times.

  • spike_times_2 (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Second spike train as array of spike times.

  • cost_factor (float) – Cost factor \(q\) for temporal shifts. Higher values penalize temporal differences more heavily.

Returns:

Victor-Purpura distance between the two spike trains.

Return type:

float

Examples

>>> import jax.numpy as jnp
>>> import braintools as braintools
>>> # Similar spike trains
>>> spikes1 = jnp.array([1.0, 2.0, 3.0])
>>> spikes2 = jnp.array([1.1, 2.1, 3.1])
>>> distance = braintools.metric.victor_purpura_distance(spikes1, spikes2, cost_factor=10.0)
>>> print(f"VP distance: {distance:.3f}")

References