私は、2Dガウス混合モデルのカーネル密度推定を推定し、座標に対するログKDEの勾配を推定するためにnumpyとscipyを使用しようとしています。 私の質問はどのようにlog KDEの勾配を推定するのですか? st.gaussian_kde()
の返信はグラデーションの計算に使用できないようですか?どんな助けもありがとう。コードを見てください。2D GMMとその勾配のカーネル密度推定の見積もり方法は?
import numpy as np
import matplotlib.pyplot as pl
import scipy.stats as st
data = np.random.multivariate_normal((0, 0), [[0.8, 0.05], [0.05, 0.7]], 100)
x = data[:, 0]
y = data[:, 1]
xmin, xmax = -3, 3
ymin, ymax = -3, 3
xx, yy = np.mgrid[xmin:xmax:100j, ymin:ymax:100j]
positions = np.vstack([xx.ravel(), yy.ravel()])
values = np.vstack([x, y])
kernel = st.gaussian_kde(values)
f = np.reshape(kernel(positions).T, xx.shape)
[gradient_numpyのドキュメント(https://docs.scipy.org/doc/numpy/reference/generated/numpy.gradient.html)が正しく理解されていれば、numpyそこから勾配を計算します。 OPが任意の点で評価される「分析的」勾配を必要とする場合は、私の答えを見てください。 – Raketenolli