exact-kantorovich-0.1.0.0: Exact Kantorovich distance between finite probability measures.
Copyright(c) Stéphane Laurent 2024
LicenseBSD-3-Clause
Maintainerlaurent_step@outlook.fr
Safe HaskellSafe-Inferred
LanguageHaskell2010

Math.Optimization.Kantorovich

Description

Computes the exact Kantorovich distance between two finite probability measures. This assumes that the probability masses are rational numbers and that the distance function takes rational values only.

Synopsis

Documentation

type RandomVariable a = Map a Rational Source #

A random variable is defined as a map from a set to the set of rational numbers. It maps an element to its probability mass.

type KantorovichValue = Rational Source #

Type for the value of the Kantorovich distance.

type KantorovichSolution a b = RandomVariable (a, b) Source #

Type for the solution of the underlying linear programming problem used to compute the Kantorovich distance. The solution is a joining of the two random variables. It is then a random variable on the Cartesian product of the sets on which the two random variables are distributed.

type KantorovichResult a b = (KantorovichValue, KantorovichSolution a b) Source #

Type for the result of the kantorovich function.

kantorovich Source #

Arguments

:: (Ord a, Ord b) 
=> RandomVariable a

first random variable

-> RandomVariable b

second random variable

-> ((a, b) -> Rational)

distance function taking positive rational values

-> Bool

whether to print the details of the simplex algorithm to stdout

-> IO (Maybe (KantorovichResult a b)) 

Kantorovich distance between two probability measures (random variables).

prettyKantorovichSolution Source #

Arguments

:: (Ord a, Ord b) 
=> Maybe (KantorovichResult a b)

an output of the kantorovich function

-> String 

Prints the random variable representing the Kantorovich solution in the style of a matrix.