libpysal.kernels.kernel¶
-
libpysal.kernels.kernel(distances, bandwidth, kernel=
'gaussian', taper=True, decay=False)[source]¶ Evaluate a kernel function over a distance array.
- Parameters:¶
- distances : ndarray¶
Array of distances.
- bandwidth : float¶
Kernel bandwidth.
- kernel : str or callable, optional¶
The kernel function to use. If a string, must be one of the predefined kernel names: ‘triangular’, ‘parabolic’, ‘gaussian’, ‘bisquare’, ‘tricube’, ‘cosine’, ‘boxcar’, ‘discrete’, ‘exponential’, ‘identity’. If callable, it should have the signature (distances, bandwidth). If None, the ‘identity’ kernel is used.
- taper : bool (default: True)¶
Set kernel = 0 for all distances exceeding the bandwith. To evaluate kernel beyond bandwith set taper=False.
- decay : bool (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:¶
Kernel function evaluated at distance values.
- Return type:¶
ndarray