Probabilities and Logarithms

What does Simon do when he is sick and free from having any lessons? Follow a course on probability theory and logarithms (which he watched four times), writing equations and trying to program a circle as an infinite number of sides. His mother spent a couple hours digging up information on logarithms and the number of sides in a circle today.

Here are Simon’s notes in Word. On probability theory, where c is the chance, t is the number of times and p – the possibilities.

Probability 28 Mar 2017

And about these equations he said that the first one is about exponents, the second is about square roots and the third one is about logarithms:

Logarithms 28 Mar 2017

The video below features the coding project that Simon built relying on what he learned about probability and applying logarithms to calculate probability. It’s the next step after Daniel Shiffman’s math tutorial, a coding challenge, covering the basics of simulating a lottery in JavaScript. (How do you pick a random number to determine if you have won or not? How do you keep track of how many times you have played the lottery? How do you display the results on a webpage?)

Simon’s project online:


Genetic Algorithm

“Mommy! Genetic algorithm is AI, ML and DL all at the same time! Scary information. It’s scary information for me,” Simon stares at me, a brand new Daniel Shiffman tutorial on intelligence and learning paused on the screen.  I come up to my little boy and hold him. We talk about AI and his fears. Does he sense the grandeur, the tsunami of technological change that is about to engulf us? “I quite like my life as it currently is”, he once told me during a similar conversation while trying to pinpoint why he sometimes feels afraid of AI.

After a short break he resumes watching Daniel Shiffman talk about the final and the most exciting chapter of his book The Nature of Code. Later the same evening Simon attempts to write a genetic algorithm code. He hasn’t finished yet when I call him to bed. He file-saves the code to resume tomorrow and sighs: “Last night, the sleeping lasted so long!” On his screen, I see written in Java:


Genetic Algorithm 28 Mar 2017


Simon’s next own code: Calculator

Since he wrote his first own code last week, Simon has attempted to write a couple more. This morning he came up with a code for a calculator in the p5 web editor (JavaScript). He managed to create the design looking exactly like his favourite Solve calculator app (on the iPad) and the buttons seemed clickable, but there must be some kind of bug in his code as nothing appears in the window. We pasted the link to entire code below — should anyone know what the problem is, please let us know in the comments!

The design:

The bug:

The code:

Question also asked at the Processing forum:

Cellular Automation

Here Simon played with cellular automation (a model used in computational science). A cellular automation consists of a regular grid of cells, each in one of a finite number of states, such as on and off.  A new generation is created according to some fixed rule (generally, a mathematical function) that determines the new state of each cell in terms of the current state of the cell and the states of the cells in its neighborhood. In the case below, the pattern Simon got resembled Pscal’s triangle with all of its even numbers “on”:

Wolfram CA Simulation 24 Mar 2017


Cellular automata can simulate a variety of real-world systems, including biological and chemical ones. Here is another one Simon made, called “Game of Life”:

Simon used Cloud9 editor, the code for both examples came from p5.js

Twitter Bots

Yesterday some of my Facebook and Twitter friends thought that I had gone mad or, at the very least, that my account had been hacked: there were strange postings appearing about random numbers and coding rainbow. What actually happened was that while I was away to Amsterdam, back at our Antwerp home Simon was working on creating Twitter bots, following a set of tutorials by Daniel Shiffman. Yesterday Simon covered  such topics as how to make a twitter image bot using node.js and Processing (node.js basics, unix commands in terminal, node package manager, OAuth, Twitter API basics, setInterval(), and triggering Processing from the command line). He also created a bot that replies to tweets.

What Simon didn’t show in the above video was how he actually controlled the tweets yesterday – via the command line where he typed in BASH:

cd node
node bot.js
cd ..

In the actual code that Simon wrote in Sublime Text in JavaScript he programmed the bot to tweet every 20 seconds:

Screen Shot Twitter Bot 26 Mar 2017

Today Simon went on with the next step of the challenge: learning how to deploy his bot to a server to “run forever and ever!” He created an account at Amazon Web Services and successfully used it, he also managed to use his CyberDuck app for sftp file upload. In the end, however< something didn’t go right wile running the new Processing sketch via the command line and nothing got published on Twitter. Simon gave up at that point. It must be mentioned that he came down with a bad cold the same evening.

In the video below, Simon explains all the steps he was taking during this second phase of the project, jiggling with a formidable number of apps and languages:



Mom, can you read me a story?

This is what Simon begged me to read to him tonight: The Nature of Code by Daniel Shiffman. Daniel Shiffman is Simon’s hero. Simon completely owns his knowledge of English, programming and trigonometry to Daniel.

Nature of Code by Daniel Shiffman reading 21 Mar 2017

Simon’s first own code: Archimedean spiral in Processing (Java).

This is so exciting! Simon has written his first Java code completely on his own! It’s an animation of the Archimedean spiral (well, we only found out later that it’s actually called this way and that it was already discovered in the 3rd century BC). Simon built his spiral playing with polar coordinates in Processing. The first version of the spiral continued to move infinitely, beyond the canvas, so Simon came up with a way to make it stop (used a constrain).

He was so modest as not to say it was his own code and only confessed it tonight when I asked which tutorial or coding challenge this was. “None”, he answered, “I made it up myself”. He then started jumping around with joy. I told him he should post his code on GitHub, which he did. Here is the link:

The following three videos show the making of the spiral step by step, with Simon’s explanations.

Here Simon creates the grid with the x- and the y-axes:

The first version of the spiral that went on forever:

Simon came up with the constrain to control the spiral:

Archimedean spiral (aka arithmetic spiral), a locus of points corresponding to the locations over time of a point moving away from a fixed point with a constant speed along a line which rotates with constant angular velocity.

The next two videos (in Dutch) are of Simon running Git from command line to show Dad how that works and ultimately placing his code on GitHub. We were quite amazed at his fluent use of BASH, considering he only used Git just once before, approximately a moth ago.

And this is what Simon did afterwards, at 10 pm, as I was trying to finally get him to bed (copying polar shapes formulas from Wikipedia):


Polar Shapes 21 Mar 2017

He fell asleep asking me what was the γ in those examples…