Imported from https://github.com/kuanzi/Bayesian_quant