This is a simple tool for visualizing the output of NetLogo’s built-in random number generators. It’s intended as a quick reference for visually-oriented NetLogo programmers (i.e. me) trying to get a feel for what effect a given choice of distribution and parameter will have on a randomization procedure. It works with all the distributions available in NetLogo: pure random, normal, poisson, exponential and gamma.
Be warned, it’s java-based and may take a while to load, or complain if you don’t have java installed. It’s about a 2mb download. It also seems to have a few bugs.
To run the code version, install a copy of NetLogo on your computer, run it and open the RandomDistributionToy.nlogo file you downloaded from the above link.
How it Works
When you click “graph”, NetLogo assigns a random number to each turtle (the turtles are hidden). The distribution of those numbers across the number scale is determined by which random number distribution you’ve chosen to use. The histogram then plots the frequency of the randomly assigned numbers across the number scale.
How to Use It
Turn on the random number distributions you would like to see by flipping on one or more of the switches on the left. Adjust the parameters for that distribution via the sliders to the right of each distribution’s switch.
Things to Notice
Since the numbers are generated randomly, the histogram should look close to the mathematical ideal of the intended distribution, but with some random “noise” around it. Lowering the number of bins used by the histogram will increase the number of turtles in each bin, smoothing out that random noise. Increasing the “sample-size”–the number of turtles generated and assigned random numbers–will likewise increase the number of turtles in each bin.
Things to Try
Try reducing the “sample-size” to low levels, say 50 or even 10. Click the “graph” repeatedly. This might give you a sense of just how random random really is.
Extending the Model
Right now this is just a utilitarian tool for NetLogo programmers. It could potentially be extended into a statistiscs teaching aid.
Credits and References
This program module was created by Hugh Stimson. It can be found at hughstimson.org/projects/randomdistributiontoy
RandomDistributionToy is copyright 2008 Hugh Stimson, and distributed under the terms of the GNU General Public License v3 (http://www.gnu.org/licenses/gpl-3.0.html). You are welcome to freely use and extend this code, under the conditions of that license. Please let me know if you do! I would be happy to integrate any improvements into this program so myself and others may benefit.
The NetLogo modeling environment is Copyright 1999-2008 by Uri Wilensky, Center for Connected Learning and Computer-Based Modeling. Northwestern University, Evanston, IL.