1

I need a simple Kernel Density Estimation with fixed bandwidth and Gaussian kernel.

Alas, in scipy.stats.gaussian_kde I saw only an automatic bandwidth selection. The set_bandwidth method, as far as I see, only multiplies the auto-selected values with some correcting ratios. And I just need to set the bandwidth I want to set.

I don't want to use my hand-written Python code for KDE: it works a bit too slow.

Don't you know any replacements of scipy.stats.gaussian_kde?

4 Answers 4

1

In scipy.stats.gaussian_kde, you can supply a scalar to the bw_method option. This will set the kde.factor variable. kde.factor is a number by which the covariance matrix is multiplied, so it should be the same as the bandwidth.

Sign up to request clarification or add additional context in comments.

2 Comments

So, I have to give it sqrt(sigma)?
You mean you want to know how the bandwidth is related to the standard deviation? They are not the same thing. You are probably looking for the formula that appears here under the section "Practical estimation of the bandwidth": en.wikipedia.org/wiki/Kernel_density_estimation
1

You might be interested in KDE in statsmodels. Example here.

Comments

1

You can also try the KDE's in scikit-learn (sklearn): http://scikit-learn.org/stable/modules/density.html It has a variety of different kernels you can try, and lets you directly set bandwidth, but apparently (!) has no methods for automatic bandwidth selection.

Comments

0

You might use the KernelSmoothing class in OpenTURNS. An example is provided in Non parametric distribution fitting and the theory is described here. There is an automatic multidimensional bandwidth rule, but the bandwidth can be set by the user. Also, the library provides the Sheather and Jones "solve-the-equation" plugin rule which is efficient for multimodal distributions and a mixed rule (which is less CPU consuming than the former).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.