kde2d_scikitlearn#
- agabpylib.densityestimation.kde.kde2d_scikitlearn(xdata, ydata, Nx=100, Ny=100, xeval=None, yeval=None, xlims=None, ylims=None, evalOnData=False, kde_bandwidth=1.0, **kwargs)#
Provide a 2D kernel density estimate for a set of data points (x_i, y_i). Make use of the scikit-learn scikitlearn.neighbours.KernelDensity class.
- Parameters:
xdata (float array) – 1D array of values of x_i
ydata (float array) – 1D array of values of y_i
xlims (tuple) – limits in x to use (xmin, xmax)
ylims (tuple) – Limits in y to use (ymin, ymax)
Nx (int) – Number of KDE samples in X (regular grid between xmin and xmax)
Ny (int) – Number of KDE samples in Y (regular grid between ymin and ymax)
xeval (float array) – Evaluate on this set of x coordinates (takes precedence over regular grid)
yeval (float array) – Evaluate on this set of y coordinates (takes precedence over regular grid)
evalOndata (boolean) – If true return the log(density) evaluated on the data (instead of the regular grid)
kde_bandwidth (float) – Bandwith for density estimator
**kwargs (dict) – Extra arguments for KernelDensity class initializer
- Returns:
log_dens – The log(density) evaluated on the regular grid (shape (Nx,Ny)), or the log(density) evaluated for the data points (shape (xdata.size,)).
- Return type:
float array