RBF interpolation: LinAlgError: singular matrix

对着背影说爱祢 提交于 2019-12-04 06:09:31

I think what you're trying to do is kernel density estimation. You can use scipy.stats.gaussian_kde for this:

import numpy as np
from scipy.stats import gaussian_kde
from matplotlib import pyplot as pp

# kernel density estimate of the PDF
kde = gaussian_kde(points)

# evaluate the estimated PDF on a grid
x,y = np.mgrid[40:101,-20:101]
z = kde((x.ravel(),y.ravel())).reshape(*x.shape)

# plot
fig,ax = pp.subplots(1,1)
ax.hold(True)
pc = ax.pcolor(x,y,z)
cb = pp.colorbar(pc)
cb.ax.set_ylabel('Probability density')
ax.plot(points[0],points[1],'o',mfc='w',mec='k')

pp.show()

The statsmodels module also has some more elaborate tools for kernel density estimation.

I got same error. Finally I found why I get the error.

you have 2 point with same coordinate. (74,2) check the values have same coordinate in 28th, 30th.

In my thinking, even if you have same value on same point it emit singular matrix error.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!