# How to use Wasserstein distance in OptimalTransport.jl

**URL:** <https://discourse.julialang.org/t/how-to-use-wasserstein-distance-in-optimaltransport-jl/98898>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 15, 2023, 9:12pm UTC](https://discourse.julialang.org/t/how-to-use-wasserstein-distance-in-optimaltransport-jl/98898 "2023-05-15T21:12:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [May 15, 2023, 9:12pm UTC](https://discourse.julialang.org/t/how-to-use-wasserstein-distance-in-optimaltransport-jl/98898/1 "2023-05-15T21:12:22Z")

</div>

Hi all,

I was hoping to compare probability distributions using [Wasserstein](https://juliaoptimaltransport.github.io/OptimalTransport.jl/dev/examples/nmf/) distance. As a starting point, I was hoping to compare two discrete probability distributions, say `[.25.,25.,25.,25]` and `[0,.5,.2,.3]`. I found this [thread](https://discourse.julialang.org/t/wasserstein-distance-for-histograms/89083), but it referenced what appears to be an abandoned package.

Thanks!

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [May 15, 2023, 11:23pm UTC](https://discourse.julialang.org/t/how-to-use-wasserstein-distance-in-optimaltransport-jl/98898/2 "2023-05-15T23:23:44Z")

</div>

Evidently, I was looking at the wrong package. Here is a simple example:

```julia
using ExactOptimalTransport
wasserstein(Categorical([.3,.7]), Categorical(.5,.5))

```
