predict_local_std

predict_local_std(X, residuals, X_eval, bandwidth)

Estimates the local standard deviation using Gaussian Kernel Smoothing.

This implements a Nadaraya-Watson estimator ([M25] Eq. 2.9-2.11) for the squared residuals, to model how noise varies across the input domain (heteroscedasticity).

[digiqual] With several inputs, each input is first divided by its standard deviation in X, so one bandwidth (in standard deviations) treats all inputs alike regardless of their units. [M25] used a single input, where this only rescales the bandwidth.

Parameters

Name Type Description Default
X np.ndarray Training inputs, shape (n_samples,) or (n_samples, n_features). required
residuals np.ndarray Mean-model residuals at X, shape (n_samples,). required
X_eval np.ndarray Points at which to estimate the standard deviation, with the same number of features as X. required
bandwidth float Gaussian kernel bandwidth, in standard deviations of the (scaled) inputs. required

Returns

Name Type Description
np.ndarray np.ndarray: Local standard deviation at each point of X_eval, shape (n_eval,).