elephant.kernels.Kernel

class elephant.kernels.Kernel(sigma, invert=False)[source]

This is the base class for commonly used kernels.

General definition of kernel:

A function K(x, y) is called a kernel function if \int{K(x, y) g(x) g(y) \textrm{d}x \textrm{d}y} \ \geq 0 \quad
\forall g \in L_2

Currently implemented kernels are:

  • rectangular
  • triangular
  • epanechnikovlike
  • gaussian
  • laplacian
  • exponential (asymmetric)
  • alpha function (asymmetric)

In neuroscience, a popular application of kernels is in performing smoothing operations via convolution. In this case, the kernel has the properties of a probability density, i.e., it is positive and normalized to one. Popular choices are the rectangular or Gaussian kernels.

Exponential and alpha kernels may also be used to represent the postynaptic current/potentials in a linear (current-based) model.

Parameters:
sigmapq.Quantity

Standard deviation of the kernel.

invert: bool, optional

If True, asymmetric kernels (e.g., exponential or alpha kernels) are inverted along the time axis. Default: False.

Raises:
TypeError

If sigma is not pq.Quantity.

If sigma is negative.

If invert is not bool.

__call__(self, t)[source]

Evaluates the kernel at all points in the array t.

Parameters:
tpq.Quantity

Vector with the interval on which the kernel is evaluated, not necessarily a time interval.

Returns:
pq.Quantity

Vector with the result of the kernel evaluations.

Raises:
TypeError

If t is not pq.Quantity.

If the dimensionality of t and sigma are different.

boundary_enclosing_area_fraction(self, fraction)[source]

Calculates the boundary b so that the integral from -b to b encloses a certain fraction of the integral over the complete kernel.

By definition the returned value is hence non-negative, even if the whole probability mass of the kernel is concentrated over negative support for inverted kernels.

Returns:
pq.Quantity

Boundary of the kernel containing area fraction under the kernel density.

Raises:
ValueError

If fraction was chosen too close to one, such that in combination with integral approximation errors the calculation of a boundary was not possible.

is_symmetric(self)[source]

In the case of symmetric kernels, this method is overwritten in the class SymmetricKernel, where it returns True, hence leaving the here returned value False for the asymmetric kernels.

Returns:
bool

True in classes SymmetricKernel, RectangularKernel, TriangularKernel, EpanechnikovLikeKernel, GaussianKernel, and LaplacianKernel. False in classes Kernel, ExponentialKernel, and AlphaKernel.