# 3. Randomness

### Topic

After the last class was about using external data for visualization, in
this class we now deal with the topic of chance and probability.

From the 20th century onwards, in very different art movements, attempts
have been made to find new forms of expression by including random
operations.

In music, for example - in very free form - by John Cage and - guided by
stochastic operations - by Iannis Xenakis.

Iannis Xenakis, N'Shima (1975)

John Cagem, Atlas Eclipticalis (1962)/p>

The trends of visual art that use the computer, that were already mentioned
in the first units, also incorporate chance in various ways. Pioneers are
Vera Molnar, Frieder Nake or Michael Noll.

On the other hand, ideas of Concrete Art can often be traced back to
mathematical or statistical principles.

### Random Walks

In his compositions Xenakis sometimes used "random walks", i.e. randomly controlled movements, which he printed and then
laid a staff over the two-dimensional graph. This is how he arrived at tone durations and heights. The example "N'Shima"
is composed in this way.

Here is a visualization of a graphic score of N'Shima:

Iannis Xenakis, N'Shima, Random Walks of sectin 8. (Andreas Pirchner)

### Random functions and chance operations in P5

Random events are often controlled by creating random numbers. Their
distribution can be controlled by a distribution function and their edges
can be limited. This way, randomness can be channelled and steered in
paths.

-> A random number can be generated in P5 with the function random().

-> RandomGaussian() can be used to generate random numbers that correspond
to the Gaussian distribution (i.e. the "bell curve").https://p5js.org/reference/#/p5/randomGaussian

-> Particularly interesting is the use of Perlin Noise. Perlin Noise was
developed by Ken Perlin for creating the CGI (Computer Generated Images) of
the movie "Tron" and is one of the rare examples where a movie Oscar was
awarded for an algorithm: https://en.wikipedia.org/wiki/Perlin_noise

### Tutorials

Please watch this video playlist by Daniel Shiffman to understand the basics and reproduce the content:

Tutorials
on Perlin Noise by Daniel Shiffman.

### Assigment

**Perlin Noise and Random Walks**

Create a sketch in which an interesting structure is created by a random walk movement that is controlled by
Perlin-Noise. Here is the coding challenge for it: Link