braintools.analysis.spike.cv#
- braintools.analysis.spike.cv(trains)#
Compute the coefficient of variation of the inter-spike intervals.
\[\mathrm{CV} = \frac{\sigma_I}{\mu_I},\]with the mean \(\mu_I\) and the population standard deviation \(\sigma_I\) (
ddof=0) of the intervals of each neuron.- Parameters:
trains (
SpikeTrains) – Spike trains withNneurons.- Returns:
CV of every neuron, shape
(N,).nanfor a neuron with fewer than 2 intervals (fewer than 3 spikes), or whose intervals are all 0.- Return type:
Array- Raises:
TypeError – If
trainsis not aSpikeTrains.
Notes
A Poisson process has \(\mathrm{CV} = 1\), a perfectly regular train \(\mathrm{CV} = 0\) [1]. The value matches
scipy.stats.variation(whichelephant.statistics.cvis) applied to the intervals, except that a single interval givesnanhere, whereasscipy.stats.variationreturns 0.Works under
jax.jitandjax.vmap, and is differentiable with respect to the spike times.References
Examples
>>> import jax.numpy as jnp >>> from braintools.spike import SpikeTrains >>> from braintools.analysis.spike import cv >>> raster = jnp.zeros((10, 2)).at[jnp.array([0, 2, 6]), 0].set(1).at[::3, 1].set(1) >>> st = SpikeTrains.from_dense(raster, dt=1.) >>> cv(st) Array([0.33333334, 0. ], dtype=float32)