You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks again for a great library! We've run into an issue where the estimated PDFs are scaled incorrectly for the ISJ method under the following conditions:
The data have a narrow standard deviation
We provide a wide grid spacing relative to the observed data
This error does not occur with Silverman's bandwidth calculation.
Below I've pasted code for replicating the issue, along with the output. Note how the ISJ approach greatly overestimates the PDF when providing our own evenly-spaced grid points. This does not occur if we narrow the range of the grid points or expand the standard deviation of the random data.
I tried to figure out what might be happening in the source, but I was unable to track down the issue, but it might have something to do with the real_bw calculation giving rise to the L factor. Thus, I'm unable to provide a PR, just an example for replicating the error, which will hopefully be useful in figuring out what's happening.
Thanks!
importnumpyasnpfromKDEpyimportFFTKDEimportmatplotlib.pyplotasplt# set up some params for the examplermin=-2rmax=2xvals=np.linspace(rmin, rmax, 512)
dat=np.random.normal(loc=0, scale=.05, size=1500)
# calculate with ISJisj=FFTKDE(kernel='epa', bw="ISJ").fit(np.array(dat))
# eval with xvalsyval_pdf_ISJ=isj.evaluate(xvals)
# eval with default valuesgps, yval_pdf_ISJ_e=isj.evaluate()
# calc with silvermansilver=FFTKDE(kernel='epa', bw="silverman").fit(np.array(dat))
yval_pdf_silverman=silver.evaluate(xvals)
# plot the dataplt.hist(dat, density=True, bins='auto', alpha=0.5)
# plot the fitsplt.plot(xvals, yval_pdf_ISJ, alpha=0.8, label='ISJ')
plt.plot(gps, yval_pdf_ISJ_e, alpha=0.8, label='ISJe')
plt.plot(xvals, yval_pdf_silverman, alpha=0.8, label='silverman')
# set the rangeplt.xlim(-0.5, .5)
# add legendplt.legend()
The text was updated successfully, but these errors were encountered:
Hi!
Thanks again for a great library! We've run into an issue where the estimated PDFs are scaled incorrectly for the ISJ method under the following conditions:
This error does not occur with Silverman's bandwidth calculation.
Below I've pasted code for replicating the issue, along with the output. Note how the ISJ approach greatly overestimates the PDF when providing our own evenly-spaced grid points. This does not occur if we narrow the range of the grid points or expand the standard deviation of the random data.
I tried to figure out what might be happening in the source, but I was unable to track down the issue, but it might have something to do with the
real_bw
calculation giving rise to theL
factor. Thus, I'm unable to provide a PR, just an example for replicating the error, which will hopefully be useful in figuring out what's happening.Thanks!
The text was updated successfully, but these errors were encountered: