Julia package for maximal couplings between two probability distributions. The package mainly implements an algorithm for obtaining random draws from a maximal coupling, as described in Hermann Þórisson's book  and in Pierre Jacob's blog post.
using Distributions using MaximalCouplings # create the maximal coupling object c = MaximalCoupling(Normal(1,2), Gamma(1, 2)) # obtain 100,000 random draws from the coupling xy_pairs = rand(c, 100000) println("Fraction of samples where X==Y: ", mean(xy_pairs[1,:] .== xy_pairs[2,:]))
Fraction of samples where X==Y: 0.68141
p = prob_couple(c) println("Probability of coupling: ", p)
Probability of coupling: 0.6812677887974173
about 2 years ago