blob: 3729d5d1fc7813c8d374919f67883e40b997d56f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import numpy as np
import pylab as pl
import ot
from ot.datasets import get_1D_gauss as gauss
reload(ot.lp)
#%% parameters
n=5000 # nb bins
# bin positions
x=np.arange(n,dtype=np.float64)
# Gaussian distributions
a=gauss(n,m=20,s=5) # m= mean, s= std
b=gauss(n,m=30,s=10)
# loss matrix
M=ot.dist(x.reshape((n,1)),x.reshape((n,1)))
#M/=M.max()
#%%
print('Computing {} EMD '.format(1))
# emd loss 1 proc
ot.tic()
emd_loss4 = ot.emd(a,b,M)
ot.toc('1 proc : {} s')
|