coded math and training sampling? add functions for estimating params