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

Carolin Villforth carovi@utu...
Mon Dec 6 12:47:12 CST 2010


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

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?




Carolin Villforth
PhD Student
Tuorla Observatory Finland and
Space Telescope Science Institute
3700 San Martin Drive
21218 Baltimore, MD
phone: +1-410-338-4334
email: carovi@utu.fi, villfort@stsci.edu

More information about the SciPy-User mailing list