scipy/scipy — pull request #3769 by perimosocordiae (2014-07-03 20:41:06+00:00)
Title: ENH: avoid repeated matrix inverse

The `sum_cov` term doesn't change, so it's faster to use a factorized version and solve.

For proof, here's a quick before and after:

In [2]: a = np.random.random((20,2000))
In [3]: b = np.random.random((20,1500))
In [4]: kde_a = gaussian_kde(a)
In [5]: kde_b = gaussian_kde(b)
In [6]: %timeit kde_a.integrate_kde(kde_b)
1 loops, best of 3: 1.43 s per loop

And after (same setup code):

In [6]: %timeit kde_a.integrate_kde(kde_b)
1 loops, best of 3: 856 ms per loop