Can I retrieve the bandwidth used in a seaborn kdeplot?

為{幸葍}努か 提交于 2021-02-11 16:50:25

问题


I am usingsns.kdeplot(data) to obtain a Kernel Density Estimate for my 1 dimensional dataset.

As I understand and having read seaborn's documentation on kdeplot, sns.kdeplot() passes bw_method="Scott" to scipy.stats.gaussian_kde to automatically obtain a rule-based bandwidth to smoothening the kde plot in question.

Can I access the bandwidth that was automatically used by seaborn for its kdeplot? My idea was to reproduce seaborn's steps through scipy.stats.gaussian_kde and applying the rule as per documentation len(data)**(-1./(1+4)) (Scott's rule) to obtain a value for bw, but I find the obtained value to produce a visually different kdeplot to seaborn's plot. In other words, what is the bw_rule, so that sns.kdeplot(data,bw=bw_rule) == sns.kdeplot(data)?

来源:https://stackoverflow.com/questions/65461136/can-i-retrieve-the-bandwidth-used-in-a-seaborn-kdeplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!