simply implementation of MRF in python