Notebooks

This page contains a list of all posts containing notebooks. You can start each notebook individually by clicking on the mybinder badges at the top of each post or you can start binder in the notebooks directory where you can browse through all notebooks. Click on the following button if you want to do that.

List of Notebooks:

  • Aug, 2019
  • Aug 15, 2019Matplotlib for publications
  • Binder

    This article shows how to create plots with matplotlib for publications where fonts and font sizes match the LaTeX document and graphics are not blocky, but allow for infinite zooming.

  • Apr, 2019
  • Apr 14, 2019Numba - @vectorize and @guvectorize
  • Binder

    In this post, I will explain how to use the @vectorize and @guvectorize decorator from Numba. You can use the former if you want to write a function which extrapolates from scalars to elements of arrays and the latter for a function which extrapolates from arrays to arrays of higher dimensions.

  • Mar, 2019
  • Mar 25, 2019Numpy - Views vs. Copies
  • Binder

    Introduction

    In one of my recent projects, I needed to accelarate a discrete choice dynamic programming model. After I changed a part of the implementation, the program was indeed faster. But, the most expensive operation according to profiling with snakeviz was now ~:0(<method 'copy' of 'numpy.ndarray' objects>). I was puzzled. I was sure that there was no use of np.copy() at all. After reading some StackOverflow posts and blog entries, it became clear that some operations and more importantly indexing methods return copies instead of views. The difference between the two is that views refer to the same underlying data in memory whereas a copy creates a new object. The disadvantages of a copy are:

    • takes more time
    • takes more memory

    But, what operations return copies?

  • Jun, 2018
  • Jun 11, 2018How to download files with Python
  • Binder

    This is a short script in python to download files, resume and to validate downloads with hash values. It is useful to distribute projects and data separately. You can find it at the end of the article. An interactive version of the notebook is available as a Binder notebook.

  • Oct, 2017
  • Oct 22, 2017The Tragedy of Titanic
  • Binder

    Analysis of survival rates on the Titanic with a placebo test for whether traveling in couples increased the likelihood of survival. An interactive version of the notebook is available by clicking on the binder badge above.