UPDATE: This draft is obsolete. Please see latest draft at

I’m pleased to announce the availability of my latest chapter on state based systems for my book “Modeling data with functional programming in R”. This chapter is the culmination of the ideas presented in the preceding chapters and presents numerous examples.

The chapter initially discusses the idea of state and how to manage it within closures. From this kernel we start to build some deterministic systems ranging from fractals, to cellular automata, and finally to a trading system modeled as a finite state machine. The chapter finishes with two probabilistic systems. The first is a Markov chain for modeling a corpus of text and the second is the Chinese restaurant process, which is used to generate the Dirichlet distribution.

As usual, comments are appreciated. The most useful comments are around comprehension and flow. If there is anything that is unclear, needs more explanation, is inconsistent, or incorrect, please let me know in the comments.

Also, my editor is always looking for more reviewers. Please get in touch if you are able to do this.

Rowe – Modeling data with functional programming in R