radage.helper module¶
- radage.helper.botev(x, n=None)[source]¶
Botev et al. bandwidth selection algorithm.
See Botev, Grotowski, and Kroese (2010) for details, in particular page 2932 doi: 10.1214/10-AOS799
Largely drawn from the MATLAB implementation by Botev, available at: http://web1.maths.unsw.edu.au/~zdravkobotev/php/kde_m.php
- radage.helper.epa_kern(u)[source]¶
Epanechnikov kernel function.
- Parameters:
u (array_like) – Array of values at which to evaluate the kernel function.
- Returns:
Values of the kernel function at the given points.
- Return type:
array_like
- radage.helper.gauss_kern(u)[source]¶
Gaussian kernel function.
- Parameters:
u (array_like) – Array of values at which to evaluate the kernel function.
- Returns:
Values of the kernel function at the given points.
- Return type:
array_like
- radage.helper.kde_base(x, x_eval, bw='adaptive', kernel='gauss', w=None, n_steps=1)[source]¶
Kernel density estimation.
If number of data are fewer than 30, use Scott’s rule for initial bandwidth estimation.
- Parameters:
x (array_like) – Observed data points.
x_eval (array_like) – Points at which to evaluate the KDE.
bw (str or float, optional) – Bandwidth, by default ‘adaptive’. Valid strings are ‘adaptive’, ‘scott’, ‘botev’
kernel (str, optional) – Kernel function to use, by default ‘epa’. Valid strings are ‘epa’, ‘gauss’.
w (array-like, optional) – Observation weights, by default None. If None, all weights are set to 1. Must be the same length as x.
n_steps (int, optional) – Number of steps for adaptive bandwidth estimation, by default 1.
- Returns:
f_hat – Kernel density estimate at the given points.
- Return type:
array_like