Imported from https://github.com/matenure/OTCoarsening