elephant.statistics.optimal_kernel_bandwidth(spiketimes, times=None, bandwidth=None, bootstrap=False)[source]

Calculates optimal fixed kernel bandwidth [st3], given as the standard deviation sigma.

Original matlab code (sskernel.m) http://2000.jukuin.keio.ac.jp/shimazaki/res/kernel.html has been ported to Python by Subhasis Ray, NCBS.


Sequence of spike times (sorted to be ascending).

timesnp.ndarray or None, optional

Time points at which the kernel bandwidth is to be estimated. If None, spiketimes is used. Default: None

bandwidthnp.ndarray or None, optional

Vector of kernel bandwidths (standard deviation sigma). If specified, optimal bandwidth is selected from this. If None, bandwidth is obtained through a golden-section search on a log-exp scale. Default: None

bootstrapbool, optional

If True, calculates the 95% confidence interval using Bootstrap. Default: False


Estimated density.


Points at which estimation was computed.


Optimal kernel bandwidth given as standard deviation sigma


Kernel bandwidths examined (standard deviation sigma).


Cost functions of bandwidth.

‘confb95’tuple of np.ndarray

Bootstrap 95% confidence interval: (lower level, upper level). If bootstrap is False, confb95 is None.


Bootstrap samples. If bootstrap is False, yb is None.

If no optimal kernel could be found, all entries of the dictionary are set to None.