The whinny of the exponential horse

[This article was first published on Statisfactions: The Sounds of Data and Whimsy » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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.packages("devtools")
library(devtools)
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.

library(playitbyhoof)
 
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 their blog: Statisfactions: The Sounds of Data and Whimsy » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)