update calculations in IPython Notebook and in d3 example