@@ -21,11 +21,11 @@ Random.seed!(1234);
2121# and $\nu$ (target measure) in 1D:
2222
2323M = 200
24- μ = fill (1 / M, M)
24+ μ = fill (1 / M, M)
2525μsupport = rand (M)
2626
2727N = 250
28- ν = fill (1 / N, N)
28+ ν = fill (1 / N, N)
2929νsupport = rand (N);
3030
3131# Now we compute the quadratic cost matrix $C_{ij} = \| x_i - x_j \|_2^2$:
@@ -133,11 +133,11 @@ norm(γ - γpot, Inf)
133133# We construct two random measures, now with different total masses:
134134
135135M = 100
136- μ = fill (1 / M, M)
136+ μ = fill (1 / M, M)
137137μsupport = rand (M)
138138
139139N = 200
140- ν = fill (1 / M, N)
140+ ν = fill (1 / M, N)
141141νsupport = rand (N);
142142
143143# We compute the quadratic cost matrix:
@@ -164,9 +164,9 @@ norm(γ - γpot, Inf)
164164
165165μsupport = νsupport = range (- 2 , 2 ; length= 100 )
166166C = pairwise (SqEuclidean (), μsupport' , νsupport' )
167- μ = exp .(- μsupport.^ 2 ./ 0.5 ^ 2 )
167+ μ = exp .(- μsupport .^ 2 ./ 0.5 ^ 2 )
168168μ ./= sum (μ)
169- ν = νsupport.^ 2 .* exp .(- νsupport.^ 2 ./ 0.5 ^ 2 )
169+ ν = νsupport .^ 2 .* exp .(- νsupport .^ 2 ./ 0.5 ^ 2 )
170170ν ./= sum (ν)
171171
172172plot (μsupport, μ; label= raw " $\m u$" , size= (600 , 400 ))
@@ -176,8 +176,11 @@ plot!(νsupport, ν; label=raw"$\nu$")
176176
177177γ = sinkhorn (μ, ν, C, 0.01 )
178178heatmap (
179- μsupport, νsupport, γ;
180- title= " Entropically regularised optimal transport" , size= (600 , 600 )
179+ μsupport,
180+ νsupport,
181+ γ;
182+ title= " Entropically regularised optimal transport" ,
183+ size= (600 , 600 ),
181184)
182185
183186# ### Quadratically regularised transport
@@ -187,8 +190,11 @@ heatmap(
187190
188191γquad = Matrix (quadreg (μ, ν, C, 5 ; maxiter= 500 ))
189192heatmap (
190- μsupport, νsupport, γquad;
191- title= " Quadratically regularised optimal transport" , size= (600 , 600 )
193+ μsupport,
194+ νsupport,
195+ γquad;
196+ title= " Quadratically regularised optimal transport" ,
197+ size= (600 , 600 ),
192198)
193199
194200# ### Sinkhorn barycenters
@@ -208,9 +214,9 @@ heatmap(
208214# $\lambda_1 \in \{0.25, 0.5, 0.75\}$.
209215
210216support = range (- 1 , 1 ; length= 250 )
211- mu1 = exp .(- (support .+ 0.5 ). ^ 2 ./ 0.1 ^ 2 )
217+ mu1 = exp .(- (support .+ 0.5 ) .^ 2 ./ 0.1 ^ 2 )
212218mu1 ./= sum (mu1)
213- mu2 = exp .(- (support .- 0.5 ). ^ 2 ./ 0.1 ^ 2 )
219+ mu2 = exp .(- (support .- 0.5 ) .^ 2 ./ 0.1 ^ 2 )
214220mu2 ./= sum (mu2)
215221
216222plt = plot (; size= (800 , 400 ), legend= :outertopright )
0 commit comments