Skip to content

Commit dcda744

Browse files
Exporting discretemeasure (#15)
* ✨ Exporting discretemeasure. * Formatting. * 📚 Adding discretemeasure docs. * Update src/utils.jl Co-authored-by: David Widmann <[email protected]> * Removed double docstring and changed text. * Update src/utils.jl Co-authored-by: David Widmann <[email protected]> * Update Project.toml Co-authored-by: David Widmann <[email protected]>
1 parent e9efd4e commit dcda744

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ExactOptimalTransport"
22
uuid = "24df6009-d856-477c-ac5c-91f668376b31"
33
authors = ["JuliaOptimalTransport"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"

docs/src/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ ot_cost(::ExactOptimalTransport.SqEuclidean, ::ExactOptimalTransport.MvNormal, :
2828
wasserstein
2929
squared2wasserstein
3030
```
31+
32+
```@docs
33+
discretemeasure
34+
```

src/ExactOptimalTransport.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ using SparseArrays
1212

1313
export emd, emd2
1414
export ot_cost, ot_plan, wasserstein, squared2wasserstein
15+
export discretemeasure
1516

1617
const MOI = MathOptInterface
1718

src/utils.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ end
1212
"""
1313
discretemeasure(
1414
support::AbstractVector,
15-
probs::AbstractVector{<:Real}=fill(inv(length(support)), length(support))
15+
probs::AbstractVector{<:Real}=fill(inv(length(support)), length(support)),
1616
)
1717
1818
Construct a finite discrete probability measure with `support` and corresponding
@@ -33,6 +33,12 @@ using KernelFunctions
3333
If `support` is a 1D vector, the constructed measure will be sorted,
3434
e.g. for `mu = discretemeasure([3, 1, 2],[0.5, 0.2, 0.3])`, then
3535
`mu.support` will be `[1, 2, 3]` and `mu.p` will be `[0.2, 0.3, 0.5]`.
36+
Also, avoid passing 1D distributions as `RowVecs(rand(3))` or `[[1],[3],[4]]`,
37+
since this will be dispatched to the multivariate case instead
38+
of the univariate case for which the algorithm is more efficient.
39+
40+
!!! warning
41+
This function and in particular its return values are not stable and might be changed in future releases.
3642
"""
3743
function discretemeasure(
3844
support::AbstractVector{<:Real},

0 commit comments

Comments
 (0)