The whinny of the exponential horse

May 13, 2012

(This article was first published on Statisfactions: The Sounds of Data and Whimsy » R, and kindly contributed to R-bloggers)

A Poisson process provides a good model for events that happen rarely. That's what von Bortkiewicz realized in 1898 when he modeled deaths by horse kick in Prussian cavalry; since it would be ungentlemanly to actually kill my readers, I instead represent the events in a Poisson process using a horse's whinny.

Poisson processes have a very unintuitive property: they're memoryless. (I'm here talking about a univariate, homogeneous Poisson process.) They have just one parameter, the expected waiting time between events. Let's say it's five seconds. The unintuitive part is that this doesn't ever change: even if you've waited 20 seconds, the expected waiting time is still five seconds. That's why it's called memoryless: the fact that an event has just happened gives you no information about when it's going to happen next, because it simply has no memory. It seems like after 20 seconds you'd be due for an event, but that's just not the way it works.

To tie together the math and the horse, here's a Poisson process with an expected waiting time of 5 seconds. Click below to hear the audio:

Neighification of the Exponential Horse

Here's the R code. I did a little tweak of playitbyr's shape_dotplot to make this clip, which you can easily install via install_github:

install_github("playitbyr", username = "statisfactions", branch = "horsie")

In order to hear the sound you'll need to install and set up the csound package and Csound; some setup tips are here.

Now you can load the package, generate the Poisson process, and listen to the output.

total <- 120 # total time (s)
expect <- 5 # expected wait time (s)
neigh <- rexp(1, rate = 1/expect)
while(neigh[length(neigh)] < total)
  neigh <- c(neigh, neigh[length(neigh)] + rexp(1, rate = 1/expect))
neighd <- data.frame(neigh = neigh)
sonify(neighd, sonaes(time = neigh)) +
  shape_horsie(relative = F) + scale_time_identity()

Matt Asher's Statistics Blog has a fun post on using a Poisson process to keep track of what you're doing right now by setting an expected wait time of 15 minutes. You can do this by simply changing expect, above, to 900 seconds and upping the total time of the sonification.

For more historical horsing around, my friend Maggie Boys is starting a business, Galloping Antiquities, to make rocking horses inspired by ancient artistic depictions of horses.

Image © Thowra_uk (Creative Commons BY)
Horse neigh sample © 3bagbrew (Creative Commons BY)

To leave a comment for the author, please follow the link and comment on his blog: Statisfactions: The Sounds of Data and Whimsy » R. offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.