added a simplified code with an example on ipython notebook