Imported from https://github.com/ruqizhang/csgmcmc