Bingo! The classic work on this is from Fader and Hardie:
https://faculty.wharton.upenn.edu/wp-content/uploads/2012/04...
A friend and I made an implementation in Python a while back:
https://faculty.wharton.upenn.edu/wp-content/uploads/2012/04...
A friend and I made an implementation in Python a while back: