elephant.kernels.RectangularKernel

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

Class for rectangular kernels.

K(t) = \left\{\begin{array}{ll} \frac{1}{2 \tau}, & |t| < \tau \\\
0, & |t| \geq \tau \end{array} \right.

with \tau = \sqrt{3} \sigma corresponding to the half width of the kernel.

Besides the standard deviation sigma, for consistency of interfaces the parameter invert needed for asymmetric kernels also exists without having any effect in the case of symmetric kernels.

Attributes:
min_cutofffloat

Half width of the kernel.

__call__(self, t)

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)

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.

property min_cutoff

Half width of the kernel.

Returns:
float

The returned value varies according to the kernel type.