code: Comparing Wasserstein and Euclidean distance

This commit is contained in:
2021-10-06 18:12:10 +02:00
parent 9ed4fc242b
commit 6a865d4925
4 changed files with 15 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import exp_mech
import numpy as np
import random
import time
from scipy.spatial.distance import cdist
'''
@ -174,7 +175,8 @@ def get_opts_from_top_h(seq, lmdks):
hist_tmp = np.copy(hist_cur)
hist_tmp[i] += 1
# Find difference from original
diff_cur = get_norm(hist, hist_tmp)
diff_cur = get_norm(hist, hist_tmp) # Euclidean
# diff_cur = get_emd(hist, hist_tmp) # Wasserstein
# Remember if it is the best that you've seen
if diff_cur < diff_min:
diff_min = diff_cur
@ -331,6 +333,12 @@ def find_lmdks(seq, lmdks, epsilon):
return lmdks_new, epsilon - eps_sel
def test():
A = np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
B = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
print(get_norm(A, B))
exit()
# Start and end points of the sequence
# # Nonrandom
# start = 1