Ipython notebook and matlab implementation agree.