This was a fun weekend project that I thought would be interesting to share as this is one of the prettier visualizations I've done in a bit. This post is a reflection of the entire GitHub repository so if you want to see more I advise you look into the actual codebase.

The logistic map is a math equation that was often used to describe population growth in natural systems, but more commonly is cited as an interesting case of chaotic nature arising out of simple mathematics.

The equation is a recursive relation wherein the updated value on the left hand side is the new population some time-step. For a typical system we would expect this to steady state to some value over many iterations. For values of the growth constant R that are just greater than ~3 the stead-state population oscillates between two values and as progresses becomes more and more chaotic.

I will give a brief summary of the components that much up the main notebook.

Helper Functions

First piece of code for this are some helper functions for the logistic map function and collecting values of the functions over iterations. The second function iterates the logistic function for i initial iterations to get to a steady state and then n iterations of points are sampled after that. Thie gives us an array that is n long containing a history of values for at a given value.

Calling Iterations

The next step is to iterate through a list of values and maintain a list for each. Later we will scatter plot the list of points against each to produce the plots you see.

When plotted with matplotlib we get the following which I find quite beautiful. I wanted to make this look better so I opted to improve the visualization using some more artistic plotting packages.

Pretty Plotting

Lastly, I use Bokeh to generate the better looking plots and save an HTML where you can explore the plot, or for the photos on here save a .PNG.

With this Bokeh code, we get some really amazing looking plots!