elephant.statistics.lvr

elephant.statistics.lvr(time_intervals, R=array(5.) * ms, with_nan=False)[source]

Calculate the measure of revised local variation LvR for a sequence of time intervals between events (Shinomoto et al., 2009).

Given a vector \(I\) containing a sequence of intervals, the LvR is defined as:

\[LvR := \frac{3}{N-1} \sum_{i=1}^{N-1} \left(1-\frac{4 I_i I_{i+1}} {(I_i+I_{i+1})^2}\right) \left(1+\frac{4 R}{I_i+I_{i+1}}\right)\]

The LvR is a revised version of the Lv, with enhanced invariance to firing rate fluctuations by introducing a refractoriness constant R. The LvR with R=5ms was shown to outperform other ISI variability measures in spike trains with firing rate fluctuations and sensory stimuli (Shinomoto et al., 2009).

Parameters:
time_intervalspq.Quantity or np.ndarray or list

Vector of consecutive time intervals. Must have time units, if not unit is passed ms are assumed.

Rpq.Quantity or int or float, optional

Refractoriness constant (R >= 0). If no quantity is passed ms are assumed. Default: 5 * pq.ms

with_nanbool, optional

If True, LvR of a spike train with less than two spikes results in a np.NaN value and a warning is raised. If False, a ValueError exception is raised with a spike train with less than two spikes. Default: False

Returns:
float

The LvR of the inter-spike interval of the input sequence.

Raises:
ValueError

If an empty list is specified, or if the sequence has less than two entries and with_nan is False.

If a matrix is passed to the function. Only vector inputs are supported.

Warns:
UserWarning

If with_nan is True and the lvr is calculated for a spike train with less than two spikes, generating a np.NaN. If R is passed without any units attached milliseconds are assumed.

Examples

>>> from elephant import statistics
>>> statistics.lvr([0.3, 4.5, 6.7, 9.3], R=0.005)
0.833907445980624