[SciPy-User] What is the kernel in gaussian_kde?
Robert Kern
robert.kern@gmail....
Wed Sep 21 17:02:58 CDT 2011
On Wed, Sep 21, 2011 at 10:57, Simon McGregor <londonien@gmail.com> wrote:
> Hi,
>
> I'm about to try and implement a simple entropy estimator using
> scipy.stats.kde. The estimator can be implemented for arbitrary
> kernels (though it won't be particularly efficient).
>
> gaussian_kde is all nicely set up to do density estimation,
> integration and various other things - but the kernel itself is not
> exposed!
>
> The scipy / numpy matrix operators are still not completely intuitive
> for me, so reverse-engineering the kernel from the code is proving a
> bit tricky. The online tutorials I have read on Gaussian kde all use
> one-dimensional examples, which obscure the meaning of the covariance
> matrix in the multi-dimensional case. My linear algebra isn't too
> strong, so again my intuitions aren't good here.
>
> If anyone could just spell out what the kernel is, I would be
> amazingly grateful.
>
> It looks like it's something like
>
> K(a-b) = exp ( (a-b) . M(a-b) / 2)
>
> ...where M is the inverse covariance matrix and . indicates the scalar
> product of two vectors. Is this right?
Up to a scale, yes. M=self.inv_cov, in this case, which is the inverse
of the covariance of the data scaled by a particular factor from the
literature. Then this is scaled by self._norm_factor.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list