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

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:

Patterns. Hilbert Curve in Processing.

This is a project about pattern. “Some people look for patterns. We call those people mathematicians”, Matt Parker said in a Numberphile video. I think I have never heard a description that would suit Simon better. He has always been looking for patterns, everywhere – in music, in toys, in ice-cream menus, in books about space or chemistry manuals. When he was little and spent days ranking planets and stars from memory, we used to think space was his true interest. Or elementary particles. Or the periodic table. Or Japanese letters. Or Greek letters. As it turned out later, he simply picked the topics that had more pattern in them, that were easy to classify. To this day, he enjoys music theory much more than actually playing the piano, and when listening to music I see him move his hand rhythmically every time a recognisable/ repetitive pattern is distinguishable.

In the video below, Simon is trying to build a Hilbert Curve (a space filling curve, a type of fractal) in Processing. The project was inspired by the math videos by 3Blue1Brown and the Koch Snowflake example by Daniel Shiffman (Chapter 8 in his book The Nature of Code, Fractals).

Links to the Hilbert Curve videos on the 3Blue1Brown channel:
https://www.youtube.com/watch?v=3s7h2MHQtxc&t=1s
https://www.youtube.com/watch?v=RU0wScIj36o

Tetris in Processing continued

Inspired by a Meth Meth Method Tetris video, Simon has come back to his Tetris project in Processing, something he started a long while ago and never finished. At the moment, the primary difficulty he experiences is having the pieces accumulate at the bottom of the grid and not vanish immediately once hit by other pieces. Work in progress.

Simon a Processing member!

Simon has become a Processing Foundation member! We love Processing! Anyone is welcome to join, just go to Processing.org to support this wonderful open source platform – what better way to celebrate this season than donate for a more enlighten future? We can rightfully say that Processing has played a huge role in Simon’s development as a young programmer so far and he definitely hopes to become an even more active member in the years to come.

Schermafbeelding 2017-12-21 om 17.52.24

The Snowball Throwing Game in Processing

Simon invented this fun game in Processing after he and his little sister had some proper winter fun outdoors in the fresh December snow (quite rare for the local climate and thus immensely cherished by the little people). The game is about throwing  snowballs in such a trajectory that they stick to one another, forming a super-snowball. After I finished filming this, the two snowball throwers had such a great time with the game that I dare say the giggling effect from of this 2D simulation overshadowed the real snowball fight that had originally inspired it. They did love playing in the real snow on the next day though, until it melted away.

 

This slideshow requires JavaScript.

Cellular Automata

Simon’s new take on cellular automata:

Wolfram CA 9 Dec 2017

Some results would make fancy knitting patters!

In case you wonder, what on earth are cellular automata:

A cellular automaton (pl. cellular automata, abbrev. CA) is studied in computer science, mathematics, physics, theoretical biology and microstructure modeling.

A cellular automaton consists of a regular grid of cells, each in one of a finite number of states, such as on and off . The grid can be in any finite number of dimensions. For each cell, a set of cells called its neighborhood is defined relative to the specified cell. An initial state (time t = 0) is selected by assigning a state for each cell. A new generation is created (advancing t by 1), 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.

The concept was originally discovered in the 1940s by Stanislaw Ulam and John von Neumann while they were contemporaries at Los Alamos National Laboratory. While studied by some throughout the 1950s and 1960s, it was not until the 1970s and Conway’s Game of Life, a two-dimensional cellular automaton, that interest in the subject expanded beyond academia. In the 1980s, Stephen Wolfram engaged in a systematic study of one-dimensional cellular automata, or what he calls elementary cellular automata; his research assistant Matthew Cook showed that one of these rules is Turing-complete. Wolfram published A New Kind of Science in 2002, claiming that cellular automata have applications in many fields of science. These include computer processors and cryptography. (Wikipedia)

Simon explains K Means Clustering

Simon has prepared this implementation of “K-Means Clustering” in Processing as a gift for Daniel Shiffman, who is plainning to talk about this Machine Learning model in one of his upcoming live sessions on the Coding Train channel.

Simon writes: K-Means Clustering is a type of Machine Learning Model. It’s for “Unsupervised Learning” (meaning you have data with no labels).

Link to Simon’s code on GitHub: https://github.com/simon-tiger/k-means-clustering

Link to pseudocode by Siraj Raval: https://www.youtube.com/watch?v=9991JlKnFmk&spfreload=1