added a function to estimate ML params per sample