@@ -92,7 +92,7 @@ sinkhorn2(μ, ν, C, ε)
9292# ```
9393# One property of the quadratically regularised optimal transport problem is that the
9494# resulting transport plan $\gamma$ is *sparse*. We take advantage of this and represent it as
95- # a sparse matrix.
95+ # a sparse matrix.
9696
9797quadreg (μ, ν, C, ε; maxiter= 500 );
9898
@@ -120,7 +120,7 @@ norm(γ - γ_pot, Inf)
120120γpot = POT. sinkhorn (μ, ν, C, ε; method= " sinkhorn_epsilon_scaling" , numItermax= 5000 )
121121norm (γ - γpot, Inf )
122122
123- # ## Unbalanced optimal transport
123+ # ## Unbalanced optimal transport
124124#
125125# [Unbalanced optimal transport](https://doi.org/10.1090/mcom/3303) deals with general
126126# positive measures which do not necessarily have the same total mass. For unbalanced
@@ -166,10 +166,8 @@ norm(γ - γpot, Inf)
166166
167167μsupport = νsupport = range (- 2 , 2 ; length= 100 )
168168C = pairwise (SqEuclidean (), μsupport' , νsupport' ; dims= 2 )
169- μ = exp .(- μsupport .^ 2 ./ 0.5 ^ 2 )
170- μ ./= sum (μ)
171- ν = νsupport .^ 2 .* exp .(- νsupport .^ 2 ./ 0.5 ^ 2 )
172- ν ./= sum (ν)
169+ μ = normalize! (exp .(- μsupport .^ 2 ./ 0.5 ^ 2 ), 1 )
170+ ν = normalize! (νsupport .^ 2 .* exp .(- νsupport .^ 2 ./ 0.5 ^ 2 ), 1 )
173171
174172plot (μsupport, μ; label= raw " $\m u$" , size= (600 , 400 ))
175173plot! (νsupport, ν; label= raw " $\n u$" )
@@ -216,10 +214,8 @@ heatmap(
216214# $\lambda_1 \in \{0.25, 0.5, 0.75\}$.
217215
218216support = range (- 1 , 1 ; length= 250 )
219- mu1 = exp .(- (support .+ 0.5 ) .^ 2 ./ 0.1 ^ 2 )
220- mu1 ./= sum (mu1)
221- mu2 = exp .(- (support .- 0.5 ) .^ 2 ./ 0.1 ^ 2 )
222- mu2 ./= sum (mu2)
217+ mu1 = normalize! (exp .(- (support .+ 0.5 ) .^ 2 ./ 0.1 ^ 2 ), 1 )
218+ mu2 = normalize! (exp .(- (support .- 0.5 ) .^ 2 ./ 0.1 ^ 2 ), 1 )
223219
224220plt = plot (; size= (800 , 400 ), legend= :outertopright )
225221plot! (plt, support, mu1; label= raw " $\m u_1$" )
0 commit comments