
differentiable approximation of bandwidth in ksdensity for optimization
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have an optimization loss term ||x* - y||^2 where x* corresponds to a quantile approximated via ksdensity (e.g., x* = ksdensity(xq, 0.9, 'Function', 'icdf')) and y is an optimization variable optimized by fmincon.
By profiling, I figured out that ksdensity internally calculates the bandwidth (smoothing parameter) using the median absolute deviation estimator which I verified below:
n = 100; d = 1;
xq = randn(n,1); % data
sigma = median(abs(xq - median(xq,1,'omitmissing')),1,'omitmissing') / 0.6745;
bw = sigma * (4/((d+2)*n))^(1/(d+4))
[~,~,bw_ref] = ksdensity(xq)
The sigma calculation involves abs(...) and median(...) -- both not continously differentiable and analytical gradients can not be derived.
A typical distribution of my xq's is shown in the attached file. Characteristic is that the the values have a positive lower bound and that the majority of the sampled values are at the lower bound and values close to the maximum are barely sampled.
My goal is to come up with a custom bandwidth calculation, appropriate for the shape of my data, which I can differentiate w.r.t. the xq's. Any suggestions what can be done here?
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!