Random Number Generator Graphing Probability

 

This random number generator Simon built in Processing simultaneously graphs the probability of the values as you “throw the dice”. This is Simon’s own code and what’s more, he has turned it into a truly scientific experiment/observation. Simon programmed the generator to automatically throw the dice every 60 frames a second (i.e. every 1/15th of a second). The graph showing the probability of certain values should increasingly resemble a perfect isoceles triangle the more throws occur, because the probability of you getting 7 is much higher than those of getting 2 or 12.

Random Number Generator Graphing Probability 9 Feb 2018Random Number Generator Graphing Probability 9 Feb 2018 2

The perfect triangle was drawn at around 4000 throws.

Simon also experimented with programming the same generator for 3 dice. The graph should then form a bell shaped curve, a parabola, and takes a longer while to shape up. “As the number of dice grows towards infinity, the distribution will change from a uniform distribution to a Gaussian distribution”, – Simon explains.

Random Number Generator Graphing Probability 9 Feb 2018 with 3 dice towards parabola 1Random Number Generator Graphing Probability 9 Feb 2018 with 3 dice towards parabola 2Random Number Generator Graphing Probability 9 Feb 2018 with 3 dice towards parabola 3Random Number Generator Graphing Probability 9 Feb 2018 with 3 dice towards parabola 4

Advertisements

Simon’s Sine Wave Tool

Simon came up with a tool (a circle where you install a pencil) to draw curved lines. He explains how the curved line actually draws the absolute value of the Sine function sin(x). “Because an absolute value of x is square root of x squared, that means that all negative values cancel out”, says Simon, that’s why the wave looks spiky.

Simon’s tool should probably be improved by making it from thicker material like thick cardboard.

dsc_0249847255387.jpg

 

Live Stream #8: Games on a grid in Processing

Simon’s live stream last night was a blast. Simon worked on two games on a grid: 15s Puzzle and Connect Four, both in Processing (Java). He had already made the 15s Puzzle before, but built the Connect Four (also called Four in a Row) without any prior preparation.

The stream got lots of views as Daniel Shiffman kindly advertised it again on his Twitter:

Let me also archive the live chat here, to save it from oblivion:

Schermafbeelding 2018-02-08 om 22.05.26Schermafbeelding 2018-02-08 om 22.06.34Schermafbeelding 2018-02-08 om 22.07.14Schermafbeelding 2018-02-08 om 22.07.32Schermafbeelding 2018-02-08 om 22.07.52Schermafbeelding 2018-02-08 om 22.08.14

Simon playing his game together with sis:

Wobbly Circles and the Center of Mass

What shape can roll well, other than a circle (wheel)? Two circles, attached together according to a formula involving a square root of two! Simon made these “wobbly circles” inspired by a Numberphile video where Matt Parker talks about how the ability to roll well (as in a wheel) is caused by the constant height of the center of mass (as opposed to a square wheel, whose center of mass goes zigzagging up and down). Wobbly wheels also have a stable height of their center of mass, hence they roll!

Simon also made a transparent version (with mom’s help):

 

DSC_0150

DSC_0151

DSC_0153

DSC_0155

DSC_0174

 

How to Square a Circle

Inspired by yet another Numberphile video, Simon is explaining why it’s impossible to turn a circle into a square with the same area using only the tools that the ancient Greeks had (this is one of the famous unsolvable math problems from Ancient Greece). We have seen, however, that the brilliant Murderous Math team have found a solution to squaring a circle! It was quite difficult to find the link to that exact page on the Murderous Math website (Simon had to dig into the html code to find it), but here it is: murderousmaths.co.uk/books/MMoE/sqcirc.htm

 

DSC_0073

Live Stream #7. Chapter 3 of Living Code: Random Numbers.

Simon’s 7th live stream on Thursday went great. He has about 230 subscribers at the moment, so there were people watching and posting encouraging comments in the chat. In the very beginning, something went wrong with the OBS software and Simon had to reboot, but he didn’t panic. I saw him telling himself that “everything is going to be all right” and it did!

The topics were:

The random() function, the p5.Vector.random2D() function, core and vector random walks, Random walk with Levy Flight, Self-avoiding random walk, Linear (Monte Carlo) and random distribution and Gaussian distribution with randomGaussian()

Simon’s course Living Code is based on Daniel Shiffman’s book The Nature of Code, but focuses on JavaScript and Simon adds his own code and features in almost every chapter.