| Copyright | (c) Stéphane Laurent 2024 | 
|---|---|
| License | BSD-3-Clause | 
| Maintainer | laurent_step@outlook.fr | 
| Safe Haskell | Safe-Inferred | 
| Language | Haskell2010 | 
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
- type RandomVariable a = Map a Rational
 - type KantorovichValue = Rational
 - type KantorovichSolution a b = RandomVariable (a, b)
 - type KantorovichResult a b = (KantorovichValue, KantorovichSolution a b)
 - kantorovich :: (Ord a, Ord b) => RandomVariable a -> RandomVariable b -> ((a, b) -> Rational) -> Bool -> IO (Maybe (KantorovichResult a b))
 - prettyKantorovichSolution :: (Ord a, Ord b) => Maybe (KantorovichResult a b) -> String
 
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.
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   | 
| -> String | 
Prints the random variable representing the Kantorovich solution in the style of a matrix.