libpysal.kernels.kernel

libpysal.kernels.kernel(distances, bandwidth, kernel='gaussian', taper=True, decay=False)[source]

Evaluate a kernel function over a distance array.

Parameters:
distancesndarray

Array of distances.

bandwidthfloat

Kernel bandwidth.

kernelstr or callable(), optional

The kernel function to use. If a string, must be one of the predefined kernel names: ‘triangular’, ‘parabolic’, ‘gaussian’, ‘bisquare’, ‘cosine’, ‘boxcar’, ‘discrete’, ‘exponential’, ‘identity’. If callable, it should have the signature (distances, bandwidth). If None, the ‘identity’ kernel is used.

taperbool (default: True)

Set kernel = 0 for all distances exceeding the bandwith. To evaluate kernel beyond bandwith set taper=False.

decaybool (default: False)

whether to calculate the kernel using the decay formulation. In the decay form, a kernel measures the distance decay in similarity between observations. It varies from from maximal similarity (1) at a distance of zero to minimal similarity (0 or negative) at some very large (possibly infinite) distance. Otherwise, kernel functions are treated as proper volume-preserving probability distributions.

Returns:
ndarray

Kernel function evaluated at distance values.