shad/ML1: add helper functions
shad/ML1: fix tabs
shad/ML1: add GEM algorithm with k optimization.