**mages' blog**, and kindly contributed to R-bloggers)

The other day I saw a fantastic exhibition of work by Bridget Riley. Karsten Schubert, who is Riley’s main agent, has a some of her most famous and influential artwork from 1960 – 1966 on display, including the seminal *Moving Squares* from 1961.

Photo of Moving Squares by Bridget Riley, 1961Emulsion on board, 123.2 x 121.3cm |

In the 1960s Bridget Riley created some great black and white artwork, which at a first glance may look simple and deterministic or sometimes random, but has fascinated me since I saw some of her work for the first time about 9 years ago at the Tate Modern.

Her work prompted a very simple question to me: When does a pattern appear random? As human beings most of our life is focused on pattern recognition. It is about making sense of the world around us, being able to understand what people are saying; seeing lots of different things and yet knowing when something is a table and when it is not. No surprise, I suppose, that pattern recognition is such a big topic in statistics and machine learning.

Neil Dodgson published some interesting research papers related to the work by Bridget Riley. In a paper from 2008 he concluded that even limited randomness can produce a great deal of complexity, such as in Riley’s *Fragment 6/9*, and hence might be so appealing to the pattern detection systems of our brains. I wonder, if it may also help to explain why some people can spend hours looking at stock market charts.

Of course I couldn’t resist trying to reproduce the *Moving Squares* in R. Here it is:

```
```

`## Inspired by Birdget Riley's Moving Squares`

x <- c(0, 70, 140, 208, 268, 324, 370, 404, 430, 450, 468,

482, 496, 506,516, 523, 528, 533, 536, 542, 549, 558,

568, 581, 595, 613, 633, 659, 688, 722, 764, 810)

y <- seq(from=0, to=840, by=70)

m <- length(y)

n <- length(x)

z <- t(matrix(rep(c(0,1), m*n/2), nrow=m))

image(x[-n], y[-m], z[-n,-m], col=c("black", "white"),

axes=FALSE, xlab="", ylab="")

```
```

```
```

However, what may look similar on screen is quite different when you see the actual painting. Thus, if you are in London and have time, make your way to the gallery in Soho. I recommend it!

**leave a comment**for the author, please follow the link and comment on their blog:

**mages' blog**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...