finish code. TODO : add comments
modify EMD.py unchecked