Nicolas Rougier, a researcher at a French computing lab, writes free books and tutorials on Python, NumPy, Matplotlib, and scientific visualization.
HN commenters praise his open books, especially From Python to Numpy, calling it the best NumPy tutorial they have read, and thank him for sharing.
This work is subtly related to chaos theory.
The nth coefficient of the ith Mandelbrot polynomial lemniscate [3] is equal to the number of possible binary trees with n nodes of height i or less. This is because z -> z^2 + c reflects coefficients recursively produced by repeated applications of the binomial theorem.
When n becomes <= i, the nth coefficient stabilizes, converging to the nth Catalan number, which is the number of possible binary trees with n nodes. The nth Catalan number is also the number of triangulations of an n+2-gon.
https://en.m.wikipedia.org/wiki/Catalan_number#Applications_in_combinatorics
Now, there is a 1-to-1 bijective mapping between binary trees of height n and node count i, and n+2 sided polygon triangulations with i segments.
https://www.r-bloggers.com/2015/07/catalan-numbers-fortriangulationsgamblers-ruinbinary/
In fact, the same associahedron in "Flipping until you are lost" is mentioned here:
https://www.researchgate.net/figure/The-bijection-between-binary-plane-trees-and-triangulations-of-a-polygon-as_fig1_225917464
What is the significance of all of this? There is currently no closed form approximation for these numbers. As simple as it might sound, we have no closed form for the number of binary trees with i nodes of height <= n. If we did, we could approximate the Mandelbrot and it would unlock new frontiers of understanding chaos theory.
Philippe Flajolet, a now-deceased titan of analytic combinatorics [2] wrote some papers on the…
I actually have no idea about that. I don't think there's an equivalent to R's base graphics, so that would seem to make matplotlib the closest thing to a standard -- seaborn [0], which I've seen used a lot lately for more advanced dataviz, lives atop it, but it's also relatively new.
People seem to have conflicted feelings about matplotlib, maybe because of its origin in MATLAB? Not that Matlab itself is bad, but I think the decision to make matplotlib's API comfortable for MATLAB users seems to cause confusion to contemporary users, even before the usual 2.x vs 3.x issues (matplotlib ported to 3.x a few years ago but many users still write Python in the 2.x style.)
Anecdotally, I feel like I see advice like "Just use plotly" more than I see recommendations to actually learn matplotlib. I actually gave up on matplotlib until I stumbled upon this comprehensive tutorial, which covers the basics and many elaborate use cases. If there's a book that does it better, I haven't heard about it:
http://www.labri.fr/perso/nrougier/teaching/matplotlib/
The matplotlib site itself is chockful of well-documented examples, but some of them seem to be significantly more verbose than they need to be. My impression is that the library is stable/ubiquitous enough that there isn't a big movement to overhaul things. Last time I looked at the API changes for v2.0 [1] (1.5.3 is stable), most of the changes had to do with default styles and stylesheets, which is non-trivial given the number of…
If you really care about extracting every possible ounce of performance out of Python's scientific stack, which relies extensively on Numpy, the best practical guide I have found for doing that is "From Python to Numpy," by Nicolas P. Rougier of Inria: https://www.labri.fr/perso/nrougier/from-python-to-numpy/
Here's a typical example of the kinds of optimizations this guide teaches you, in this case by avoiding the creation of temporary copies of Numpy arrays in memory:
# Create two int arrays, each filled with with one billion 1's.
X = np.ones(1000000000, dtype=np.int)
Y = np.ones(1000000000, dtype=np.int)
# Add 2 * Y to X, element by element:
# Slowest
%time X = X + 2.0 * Y
100 loops, best of 3: 3.61 ms per loop
# A bit faster
%time X = X + 2 * Y
100 loops, best of 3: 3.47 ms per loop
# Much faster
%time X += 2 * Y
100 loops, best of 3: 2.79 ms per loop
# Fastest
%time np.add(X, Y, out=X); np.add(X, Y, out=X)
100 loops, best of 3: 1.57 ms per loop
That's a 2.3x speed improvement (from 3.61 ms to 1.57 ms) on a simple vector operation (your mileage will vary!).[1] This only scratches the surface. The guide goes into quite a bit of explicit detail about how Numpy arrays are constructed and stored in memory and always explains the underlying reasons why some operations are faster than others. In addition, the guide has a section titled "Beyond Numpy" that points to even more ways of improving performance, e.g., by using Cython,…
The article isn't loading for me right now, but I thought I'd mention co-inductive types and how they relate to "interaction".
In Coq, co-inductive types are used to model infinite objects like (never-ending) streams or (non-terminating) program executions.
Inductive List (A: Set): Set :=
| Nil: List A
| Cons : A -> List A -> List A.
CoInductive Stream (A: Set): Set :=
| SCons: A -> Stream A -> Stream A.
Fixpoint len {A: Set} (x: List A): nat :=
match x with
| Nil => 0
| Cons _ y => 1 + len y
end.
CoFixpoint ones : Stream nat :=
SCons nat 1 ones.
If you want to talk about how systems interact with the world, you can use bisimilarity relations to prove "these two systems interact with the world in the same way".
You can also use co-inductive types to embed the temporal logic of actions (TLA) in Coq; TLA is the language Leslie Lamport works with for "Specifying Systems".
* http://www.labri.fr/perso/casteran/RecTutorial.pdf
* http://www.amazon.com/Specifying-Systems-Language-Hardware-Engineers/dp/032114306X
* http://en.wikipedia.org/wiki/Bisimulation
Modern computer operating systems won't let you arbitrarily switch pixels on the screen on or off, so you'd need to either write a program that uses a GUI library to create a window, controls, etc, or generate an image file you can open in a viewer.
For Python, matplotlib(1) will let you generate plots and graphs, including simple x/y graphs, or you could use the built-in TkInter(2) library to do a simple GUI with a drawing canvas.
(1)http://www.labri.fr/perso/nrougier/teaching/matplotlib/
(2) http://www.python-course.eu/tkinter_canvas.php
Love Mr. Rougier's open books. I supported this one while it was in development and I wasn't disappointment by the final product.
I've long awaited for him to finish "Python & OpenGL for Scientific Visualization" [0] but I'll take this in the mean time :P
[0] https://www.labri.fr/perso/nrougier/python-opengl/#python-opengl-for-scientific-visualization