[SciPy-User] changing covariance factor in scipy.stats.kde.gaussian_kde

Robert Kern robert.kern at gmail.com
Mon Dec 6 13:48:39 EST 2010


On Mon, Dec 6, 2010 at 12:47, Carolin Villforth <carovi at utu.fi> wrote:
> Hello,
>
> I have a question concerning the usage of gaussian_kde. I am trying to change the covariance factor for the KDE, this is what I am doing it at the moment:
>
> myKDE = scipy.stats.kde.gaussian_kde(data)
> myKDE.covariance_factor = myKDE.silverman_factor
> myKDE._compute_covariance()
>
> The last line seems to be necessary for the changes to take effect.
>
> While the above code works, this might create quite an overhead since _compute_variance is executed twice, once in __init__ and then again after the covariance factor has been changed. If I understood correctly, this is not really necessary since silverman_factor does not depend on outputs from _compute_covariance. Also, I always assumed that one should avoid calling '._functions' from outside the class.
>
> Is there another way to change the covariance factor?

Subclass.

-- 
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