#! /usr/bin/env python

import numpy
import pylab

pylab.ion()
pylab.xticks(range(2,13))
pylab.xlabel("Result")
pylab.ylabel("Occurrences")

hist = numpy.zeros(11)

for i in xrange(1000000) :

    dice1 = numpy.random.random_integers(1, 6)
    dice2 = numpy.random.random_integers(1, 6)
    hist[dice1 + dice2 - 2] += 1

    pylab.title("Number of dice rolls: %d" % i)
    pylab.bar(numpy.arange(1.5,12.5), hist, width=1, fc="b")
    pylab.plot(numpy.arange(2,13), hist, "r-")

