Imported from https://github.com/pbecker93/ExpectedInformationMaximization
