Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This KDE implementation is faster than scipy.gaussian_kde. According to my test between ~10 times faster (for ~1000 points) and ~40 times faster (for ~10000 points). This implementation includes a boundary correction (using the reflection method). I think the only caveat is that it will not work very nice if the number of data points is low (probably lower than ~1000/500), in such a cases the tails of the distributions are not estimated very nice. Nevertheless I think this is OK, given that in general people uses at least 1000 samples.
The next image is an example of a KDE estimation without boundary corrections (the SciPy implementation)

And this is an example with boundary correction (the implementation in this PR)
I know is a small detail, but in my experience KDE plots without the correction can be confusing to those unaware of how KDE estimation works, or at least those unfamiliar with PyMC3/scipy-KDE.
This is an adaptation of the code from this repository and made some modifications. I made this change following this suggestion arviz-devs/arviz#5