Distributions

與 Kullback-Leibler 散度相比,Wasserstein 度量的優勢是什麼?

  • August 1, 2017

Wasserstein 度量Kullback-Leibler 散度之間的實際區別是什麼?Wasserstein 度量也稱為地球移動器的距離

來自維基百科:

Wasserstein(或 Vaserstein)度量是在給定度量空間 M 上的概率分佈之間定義的距離函數。

Kullback-Leibler 散度是衡量一個概率分佈如何偏離第二個預期概率分佈的量度。

我已經看到 KL 被用於機器學習實現,但我最近遇到了 Wasserstein 指標。是否有關於何時使用其中一種的良好指南?

Wasserstein(我沒有足夠的聲譽來使用或創建新標籤Earth mover's distance。)

當考慮 Wasserstein 度量與 KL 散度相比的優勢時,最明顯的一個是 W 是度量而 KL 散度不是,因為 KL 不是對稱的(即一般)並且不滿足三角不等式(即一般不成立)。

至於實際差異,最重要的一點是,與 KL(和許多其他度量)不同,Wasserstein 考慮了度量空間,而這在不太抽象的術語中意味著什麼也許最好通過一個例子來解釋(隨意跳過如圖所示,僅用於生成它的代碼):

# define samples this way as scipy.stats.wasserstein_distance can't take probability distributions directly
sampP = [1,1,1,1,1,1,2,3,4,5]
sampQ = [1,2,3,4,5,5,5,5,5,5]
# and for scipy.stats.entropy (gives KL divergence here) we want distributions
P = np.unique(sampP, return_counts=True)[1] / len(sampP)
Q = np.unique(sampQ, return_counts=True)[1] / len(sampQ)
# compare to this sample / distribution:
sampQ2 = [1,2,2,2,2,2,2,3,4,5]
Q2 = np.unique(sampQ2, return_counts=True)[1] / len(sampQ2)

fig = plt.figure(figsize=(10,7))
fig.subplots_adjust(wspace=0.5)
plt.subplot(2,2,1)
plt.bar(np.arange(len(P)), P, color='r')
plt.xticks(np.arange(len(P)), np.arange(1,5), fontsize=0)
plt.subplot(2,2,3)
plt.bar(np.arange(len(Q)), Q, color='b')
plt.xticks(np.arange(len(Q)), np.arange(1,5))
plt.title("Wasserstein distance {:.4}\nKL divergence {:.4}".format(
   scipy.stats.wasserstein_distance(sampP, sampQ), scipy.stats.entropy(P, Q)), fontsize=10)
plt.subplot(2,2,2)
plt.bar(np.arange(len(P)), P, color='r')
plt.xticks(np.arange(len(P)), np.arange(1,5), fontsize=0)
plt.subplot(2,2,4)
plt.bar(np.arange(len(Q2)), Q2, color='b')
plt.xticks(np.arange(len(Q2)), np.arange(1,5))
plt.title("Wasserstein distance {:.4}\nKL divergence {:.4}".format(
   scipy.stats.wasserstein_distance(sampP, sampQ2), scipy.stats.entropy(P, Q2)), fontsize=10)
plt.show()

兩對不同分佈的 Wasserstein 度量和 Kullback-Leibler 散度 這里紅色和藍色分佈之間的度量對於 KL 散度是相同的,而 Wasserstein 距離測量使用 x 軸作為“道路”將概率質量從紅色狀態傳輸到藍色狀態所需的工作。這個度量顯然越大,概率質量越遠(因此別名地球移動器的距離)。因此,您要使用哪一個取決於您的應用領域和您要測量的內容。需要注意的是,除了 KL 散度之外,還有其他選項,例如 Jensen-Shannon 距離,它們是適當的度量標準。

引用自:https://stats.stackexchange.com/questions/295617

comments powered by Disqus