1
- # # 1D Cases
1
+ # # One-Dimensional Cases
2
2
#
3
3
# The 1D case in Optimal Transport is a special case where one can
4
4
# easily obtain closed form solutions efficiently
@@ -18,36 +18,36 @@ using StatsPlots
18
18
using LinearAlgebra
19
19
using Random
20
20
21
- Random. seed! (1234 )
21
+ Random. seed! (1234 );
22
22
23
23
# ## Continuous Distribution
24
24
#
25
25
# In the 1D case, when the source measure $\mu$ is continuous and the cost function
26
26
# has the form ``c(x, y) = h(|x - y|)`` where ``h`` is a convex function,
27
27
# the optimal transport plan is the Monge map
28
28
# ```math
29
- # T = F_\\ nu^{-1} \\ circ F_\ \mu
29
+ # T = F_\nu^{-1} \circ F_\mu
30
30
# ```
31
- # where ``F_\\ mu`` is the cumulative distribution function of `μ` and ``F_\ \nu^{-1}`` is the
31
+ # where ``F_\mu`` is the cumulative distribution function of `μ` and ``F_\nu^{-1}`` is the
32
32
# quantile function of `ν`.
33
33
# In this setting, the optimal transport cost can be computed as
34
34
# ```math
35
- # \\ int_0^1 c(F_\\ mu^{-1}(x), F_\\ nu^{-1}(x)) \ \mathrm{d}x
35
+ # \int_0^1 c(F_\mu^{-1}(x), F_\nu^{-1}(x)) \mathrm{d}x
36
36
# ```
37
- # where ``F_\\ mu^{-1}`` and ``F_\ \nu^{-1}`` are the quantile functions of `μ` and `ν`,
37
+ # where ``F_\mu^{-1}`` and ``F_\nu^{-1}`` are the quantile functions of `μ` and `ν`,
38
38
# respectively.
39
39
#
40
40
# We start by defining the distributions.
41
41
42
42
μ = Normal (0 , 1 )
43
43
44
44
N = 10
45
- ν = Poisson (N)
45
+ ν = Poisson (N);
46
46
47
47
# Nest, we define a cost function.
48
48
c (x, y) = (abs (x - y))^ 2 # could have used `sqeuclidean` from `Distances.jl`
49
49
50
- T = ot_plan (c, μ, ν)
50
+ T = ot_plan (c, μ, ν);
51
51
52
52
# `T` is the Monge Map. Let's visualize it.
53
53
p1 = plot (μ; label= ' μ' )
0 commit comments