Wasserstein distance, also known as Earth Mover's Distance, is a mathematical method used to measure the distance between two probability distributions. Compared with traditional distance measurement methods such as Euclidean distance, Wasserstein distance more comprehensively considers the similarity between distributions and the relationship between geometric distances, making it more suitable for describing the similarity of high-dimensional data sets. Wasserstein distance is calculated by the minimum total cost required to transform one distribution into another. This cost can be interpreted as the effort required to move mass in a distribution from one location to another. Therefore, the Wasserstein distance can be viewed as the cost of mass transfer between two distributions. This makes Wasserstein distance widely used in many fields, including image processing, natural language processing, economics, etc. By considering the similarity and geometric distance between distributions
The definition of Wasserstein distance is based on minimizing the cost required to transform one distribution into another. This cost can be arbitrary, but usually refers to the cost of moving mass from one location to another in a distribution, which can be expressed as the product of the distance between the two locations and the mass. The value of Wasserstein distance is equal to the minimum value of the cost of all possible transformation solutions.
Mathematically, the Wasserstein distance can be defined as:
W_p(\mu,\nu)=\left(\inf_{\ gamma\in\Gamma(\mu,\nu)}\int_{\mathbb{R}^d \times \mathbb{R}^d} |x-y|^p d\gamma(x,y)\right)^{ 1/p}
Among them, \mu and \nu are two probability distributions, \Gamma(\mu,\nu) are all probability distributions that convert \mu to \nu A set of \gamma(x,y) represents the conversion probability corresponding to (x,y). In the Wasserstein distance, p \geq 1 is a constant, usually p=1 or p=2. When p=1, the Wasserstein distance is also called the Earth Mover's Distance because it can be viewed as a measure of the minimum number of operations required to move one distribution to another.
In order to better understand the concept of Wasserstein distance, we can consider a simple example: Suppose we have two one-dimensional probability distributions P and Q, which are in the interval [0 ,1] and [0.5,1.5] uniformly distributed. We can use Python and Scipy libraries to calculate the Wasserstein distance between them.
import numpy as np from scipy.stats import wasserstein_distance # 定义两个概率分布 P 和 Q P = np.ones(100) / 100 Q = np.ones(100) / 100 Q[50:] = 0 # 计算它们之间的Wasserstein distance w_dist = wasserstein_distance(P, Q) print("Wasserstein distance:", w_dist)
In this example, we use the numpy library to generate two 100-element probability distributions, both of which are uniformly distributed. Then, we set the last 50 elements of the second distribution Q to 0 to simulate its distribution on the interval [0.5,1]. Finally, we calculate the Wasserstein distance between them using the wasserstein_distance function in the Scipy library. After running the code, we can get the output:
Wasserstein distance: 0.5
This means that the minimum cost required to transform distribution P into distribution Q is 0.5. In this example, we can interpret it as the minimum distance required to move a mound of length 0.5 into a pit of length 0.5.
In short, Wasserstein distance is a method used to measure the distance between two probability distributions, which takes into account the relationship between the similarity and geometric distance between distributions. It has many applications, such as loss functions in generative adversarial networks (GAN) and similarity measures in image retrieval.
The above is the detailed content of Wasserstein distance. For more information, please follow other related articles on the PHP Chinese website!

Running large language models at home with ease: LM Studio User Guide In recent years, advances in software and hardware have made it possible to run large language models (LLMs) on personal computers. LM Studio is an excellent tool to make this process easy and convenient. This article will dive into how to run LLM locally using LM Studio, covering key steps, potential challenges, and the benefits of having LLM locally. Whether you are a tech enthusiast or are curious about the latest AI technologies, this guide will provide valuable insights and practical tips. Let's get started! Overview Understand the basic requirements for running LLM locally. Set up LM Studi on your computer

Guy Peri is McCormick’s Chief Information and Digital Officer. Though only seven months into his role, Peri is rapidly advancing a comprehensive transformation of the company’s digital capabilities. His career-long focus on data and analytics informs

Introduction Artificial intelligence (AI) is evolving to understand not just words, but also emotions, responding with a human touch. This sophisticated interaction is crucial in the rapidly advancing field of AI and natural language processing. Th

Introduction In today's data-centric world, leveraging advanced AI technologies is crucial for businesses seeking a competitive edge and enhanced efficiency. A range of powerful tools empowers data scientists, analysts, and developers to build, depl

This week's AI landscape exploded with groundbreaking releases from industry giants like OpenAI, Mistral AI, NVIDIA, DeepSeek, and Hugging Face. These new models promise increased power, affordability, and accessibility, fueled by advancements in tr

But the company’s Android app, which offers not only search capabilities but also acts as an AI assistant, is riddled with a host of security issues that could expose its users to data theft, account takeovers and impersonation attacks from malicious

You can look at what’s happening in conferences and at trade shows. You can ask engineers what they’re doing, or consult with a CEO. Everywhere you look, things are changing at breakneck speed. Engineers, and Non-Engineers What’s the difference be

Simulate Rocket Launches with RocketPy: A Comprehensive Guide This article guides you through simulating high-power rocket launches using RocketPy, a powerful Python library. We'll cover everything from defining rocket components to analyzing simula


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download
The most popular open source editor