This repository hosts some Jupyter Notebooks, covering various subjects. Go to nbviewer to read them.
At the beginning, this repository was only here to host some small experiments, for me to learn how to use the wonderful Jupyter tools correctly (baby notebooks 🍼)...
- The first notebooks I wrote are small tutorials for 🐚
bash
commands (or some of my command-line scripts), see for example a tutorial on head and a tail (on GitHub?).
I am a passionate user of the Python programming language.
-
This notebook written for the Pi Day 2017 (on GitHub?) demonstrates a dozen of easy algorithms to compute from 10 to 100000 digits of the number pi.
-
This notebook implements a simple example of the simulated annealing algorithm (on GitHub?) to minimize black-box functions 😎.
-
This notebook shows a hand-written and clear implementation (on GitHub?) of several Hashing functions, like
MD5
,SHA1
, and all variants ofSHA2
(SHA256
,SHA224
,SHA512
,SHA384
). -
This notebook shows a manual implementation (on GitHub?) of the Lempel-Ziv complexity in pure Python, and then as optimized Python code, with Cython or Numba. I also wrote a version in Julia (in the same notebook), and compare the 4 implementations! I then published my code as a Pypy package, see here on pypi.org.
-
This notebook shows a hand-written and clear implementation (on GitHub?) of several Pseudo-Random Number Generators, including the famous Mersenne twister algorithm, and then uses it to samples from the most famous discrete and continuous distributions, showcasing use of the Inverse-Transform method and Acceptance-Rejection method (cf. Markov Chain Monte-Carlo methods).
-
🇫🇷 Ce notebook en français présente les problèmes de bandits multi-bras stochastiques (on GitHub?) (multi-armed bandit, MAB), et les algorithmes dits "de bandits" pour les résoudre (UCB "Upper Confidence Bounds", Thompson Sampling, Approximated Finite-Horizon Gittins index etc).
-
🇫🇷 I corrected some maths & programming problems from the annals of the CentraleSupelec national competitive exam (in France), in this notebook Oraux_CentraleSupelec_PSI__Juin_2017.ipynb (on GitHub?) (for this kind of oral exam).
- I also wrote some notebooks on numerical simulations of dice games 🇫🇷 Voir ce sous-dossier (ou sur GitHub?) / :gb: See this sub-folder (or on GitHub?).
- This notebook shows some "obfuscated" code, producing (on GitHub?) ✨ nice figures... Or maybe they are pieces of code art 🎨 ?
I will try to write more artistic notebooks, showcasing nice pieces of code 🎨!
-
This small notebook (on GitHub?) is a fun experiment, where I tried to use James Powell (@dutc) rwatch module to write a Python context manager to add a Gaussian white noise to every numbers inside the context... Something like:
with noise(): x = 10
will producex = 10.325
for instance... It fails, but I almost got it, and it works (without breaking the interpreter) for complex numbers. That's already intersting! -
This notebook (on GitHub?) is a small experiment, written quickly, about floating-point error propagation when using a non-naive polynomial multiplication with evaluation-and-interpolation. Sadly, this approach fails!
-
A tiny presentation on how to do time/memory profiling (on GitHub?) from inside the Jupyter notebook interface, with various approaches.
-
This notebook shows how to register a custom HTML writer for builtins or user-defined types in IPython and Jupyter (on GitHub?), for the sake of the example I wrote a nice LaTeX/MathJax-powered print function that nicely displays polynomials from the
numpy.polynomial.Polynomial
module or class. -
A small benchmark between Python, Pypy and Julia for the Romberg numerical integration algorithm (on GitHub?). Julia is the fastest, but Pypy is very fast too 🐍 !
-
Demo of the RISE Jupyter extension to easily write a dynamic slideshow in a Jupyter notebook, for Python (on GitHub?) and for OCaml (on GitHub?) 📢.
- Some notebooks are written in French 🇫🇷, mainly documents written for the preparation to the highly competitive French national exam to become a professor (aka the "agrégation"), as since 2016 I am a teaching assistant at ENS de Rennes in the Computer Science department, for the "Fundamental Computer Science" minor option (D) for the agrégation exam. 🇫🇷 Voir ce sous-dossier (ou sur GitHub) / :gb: See this sub-folder (or on GitHub).
And more will come... soon! 🚅
- Either directly in GitHub: see the list of notebooks;
- Or on nbviewer.jupiter.org: list of notebooks.
Anyone can use the mybinder.org website (by clicking on the icon above) to run the notebook in her/his web-browser. You can then play with it as long as you like, for instance by modifying the values or experimenting with the code.
Note: Only the Python kernel is supported on the MyBinder interface!
All the requirements can be installed with pip
and by running a few python -m ...
commands.
Note: if you use Python 3 instead of Python 2, you might have to replace
pip
andpython
bypip3
andpython3
in the next commands (if both pip and pip3 are installed).
2.a. Jupyter Notebook and IPython
sudo pip install jupyter ipython
It will also install all the dependencies, afterward you should have a jupyter-notebook
command (or a jupyter
command, to be ran as jupyter notebook
) available in your PATH
:
$ whereis jupyter-notebook
jupyter-notebook: /usr/local/bin/jupyter-notebook
$ jupyter-notebook --version # version >= 4 is recommended
4.2.1
They are only needed to run the notebooks written for Bash or Octave (or OCaml):
2.b.1. GNU Bash kernel
- You have to have
bash
installed (already there on all Linux distribution, installable withbrew
ormacports
on Mac OS, available on Windows throughcygwin
):
$ bash --version | head -n1
GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu)
- And then install the kernel
bash_kernel
with these two commands:
sudo pip install bash_kernel
python -m bash_kernel.install
2.b.2. GNU Octave kernel
- You have to have
octave
installed (installable with the package manager on major Linux distributions (apt-get
,pacman
,yum
etc), installable withbrew
ormacports
on Mac OS, available on Windows throughcygwin
or natively):
$ octave --version | head -n1
GNU Octave, version 4.0.0
- Your version of Octave should be installed with gnuplot support (it is usually the case):
$ gnuplot --version | head -n1
gnuplot 5.0 patchlevel 1
- And then install the kernel
bash_kernel
with these two commands:
sudo pip install octave_kernel
python -m octave_kernel.install
2.b.3. OCaml kernel
It is quite easy to install, with opam:
opam install jupyter
I started by using this OCaml kernel called IOCaml. The instructions were not so simple, cf. the tutorial by @andrewray on iocaml's wiki. It was prone to some bugs, and I had to manually implement a script to be able to convert the notebooks to PDF with
jupyter-nbconvert --to pdf
. Note that I also had to write a custom Exporter for jupyter-nbconvert in order to convert the notebooks to OCaml scripts (.ml
).
- More information about notebooks (on the documentation of IPython) or on the FAQ on Jupyter's website.
- More information about mybinder.org: on this example repository.
All the notebooks in this repository are published under the terms of the MIT License (file LICENSE.txt). © Lilian Besson, 2016-17.