Random Distribution Toy

Description

This is a simple tool for visu­al­izing the output of NetLogo’s built-​​in random number gen­er­a­tors. It’s intended as a quick ref­er­ence for visually-​​oriented NetLogo pro­gram­mers (i.e. me) trying to get a feel for what effect a given choice of dis­tri­b­u­tion and para­meter will have on a ran­dom­iza­tion pro­ce­dure. It works with all the dis­tri­b­u­tions avail­able in NetLogo: pure random, normal, poisson, expo­nen­tial and gamma.


Running the Program

Online Version

Be warned, it’s java-​​based and may take a while to load, or com­plain if you don’t have java installed. It’s about a 2mb down­load. It also seems to have a few bugs.

Stand-​​alone Code

To run the code ver­sion, install a copy of NetLogo on your com­puter, run it and open the RandomDistributionToy.nlogo file you down­loaded from the above link.


Documentation

How it Works

When you click “graph”, NetLogo assigns a random number to each turtle (the tur­tles are hidden). The dis­tri­b­u­tion of those num­bers across the number scale is deter­mined by which random number dis­tri­b­u­tion you’ve chosen to use. The his­togram then plots the fre­quency of the ran­domly assigned num­bers across the number scale.

How to Use It

Turn on the random number dis­tri­b­u­tions you would like to see by flip­ping on one or more of the switches on the left. Adjust the para­me­ters for that dis­tri­b­u­tion via the sliders to the right of each distribution’s switch.

Things to Notice

Since the num­bers are gen­er­ated ran­domly, the his­togram should look close to the math­e­mat­ical ideal of the intended dis­tri­b­u­tion, but with some random “noise” around it. Lowering the number of bins used by the his­togram will increase the number of tur­tles in each bin, smoothing out that random noise. Increasing the “sample-size”–the number of tur­tles gen­er­ated and assigned random numbers–will like­wise increase the number of tur­tles in each bin.

Things to Try

Try reducing the “sample-​​size” to low levels, say 50 or even 10. Click the “graph” repeat­edly. This might give you a sense of just how random random really is.

Extending the Model

Right now this is just a util­i­tarian tool for NetLogo pro­gram­mers. It could poten­tially be extended into a sta­tis­tiscs teaching aid.

Credits and References

This pro­gram module was cre­ated by Hugh Stimson. It can be found at hugh​stimson​.org/​p​r​o​j​e​c​t​s​/​r​a​n​d​o​m​d​i​s​t​r​i​b​u​t​i​o​n​toy

License

RandomDistributionToy is copy­right 2008 Hugh Stimson, and dis­trib­uted under the terms of the GNU General Public License v3 (http://​www​.gnu​.org/​l​i​c​e​n​s​e​s​/​g​p​l​-​3​.​0​.​h​tml). You are wel­come to freely use and extend this code, under the con­di­tions of that license. Please let me know if you do! I would be happy to inte­grate any improve­ments into this pro­gram so myself and others may benefit.

The NetLogo mod­eling envi­ron­ment is Copyright 1999–2008 by Uri Wilensky, Center for Connected Learning and Computer-​​Based Modeling. Northwestern University, Evanston, IL.

leave a comment