Skip to content

Commit 40a1808

Browse files
authored
Correcting the 1D example (#150)
* 📚 Correcting 1D example * 📚 Correcting 1D example
1 parent 06bcd71 commit 40a1808

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed
File renamed without changes.
File renamed without changes.

examples/1D/script.jl renamed to examples/OneDimension/script.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# # 1D Cases
1+
# # One-Dimensional Cases
22
#
33
# The 1D case in Optimal Transport is a special case where one can
44
# easily obtain closed form solutions efficiently
@@ -18,36 +18,36 @@ using StatsPlots
1818
using LinearAlgebra
1919
using Random
2020

21-
Random.seed!(1234)
21+
Random.seed!(1234);
2222

2323
# ## Continuous Distribution
2424
#
2525
# In the 1D case, when the source measure $\mu$ is continuous and the cost function
2626
# has the form ``c(x, y) = h(|x - y|)`` where ``h`` is a convex function,
2727
# the optimal transport plan is the Monge map
2828
# ```math
29-
# T = F_\\nu^{-1} \\circ F_\\mu
29+
# T = F_\nu^{-1} \circ F_\mu
3030
# ```
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
3232
# quantile function of `ν`.
3333
# In this setting, the optimal transport cost can be computed as
3434
# ```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
3636
# ```
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 `ν`,
3838
# respectively.
3939
#
4040
# We start by defining the distributions.
4141

4242
μ = Normal(0, 1)
4343

4444
N = 10
45-
ν = Poisson(N)
45+
ν = Poisson(N);
4646

4747
# Nest, we define a cost function.
4848
c(x, y) = (abs(x - y))^2 # could have used `sqeuclidean` from `Distances.jl`
4949

50-
T = ot_plan(c, μ, ν)
50+
T = ot_plan(c, μ, ν);
5151

5252
# `T` is the Monge Map. Let's visualize it.
5353
p1 = plot(μ; label='μ')

0 commit comments

Comments
 (0)