a ruby sparkline showing variation

Back in May’s Carnival of the Agilists I referenced a post by Clarke Ching in which he suggests we can learn a lot about variation in a complex process by simply flipping coins. When I tried the simulation a few times with Excel I found, as expected, that heads and tails don’t always occur in equal measure. But that was a pain to do, so I’ve made it easier. I’ve written a little Ruby program that simulates 1000 coin tosses; you can get it from github.

The simulation generates SVG images; if you can view those in your browser, you can see three consecutive runs here, here and here.

(Disclaimer: The images are SVG. It works fine in Firefox, but if you use IE you may need to install some kind of viewer.)

Advertisements

3 thoughts on “a ruby sparkline showing variation

  1. There is a kind of sparklines gem here:

    http://nubyonrails.com/pages/sparklines

    I added a histogram (bar chart) function to that library, and colored bars that were above a given threshold (like the rest of the drawing styles do). I don’t think that code went into the reworked version, although I was told it would be.

    Anyway, things I like:
    1) diverse set of drawing styles
    2) not too rails-y, or rails oriented; nice generic Ruby (yay!) library is great
    3) SVG is fine, since there’s lots of convertered (RMagick works fine for people trying to get things done, counter-propaganda aside)

    Nice sparkline though :)

  2. Actually I tried all of the existing gems and libraries, both for sparklines and for SVG — and in the end I just wrote a bunch of code that spits out SVG as text. Maybe I should tidy it up and put it up on RAA sometime…

  3. Pingback: i’ve moved my code « silk and spinach

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s