Galton Box

Galton Box preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)



Tagged by Reuven M. Lerner almost 11 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 752 times • Downloaded 67 times • Run 0 times
Download the 'Galton Box' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


A Galton box is a triangular board that contains several rows of staggered but equally spaced pegs. Balls are dropped from the top, bounce off the pegs and stack up at the bottom of the triangle. The resulting stacks of balls have a characteristic shape.

The model enables you to observe how nature produces the binomial coefficients from Pascal's Triangle and their relation to a Gaussian bell-shaped normal curve. The model can also simulate coin tossing experiments with biased coins which result in skewed distributions

There are many applications for the concepts encompassed in a Galton box. People employed in a wide variety of fields use binomial and normal distributions to make precise calculations about the likelihood of events or groups of events occurring.


With the default settings, the model reproduces a traditional Galton box. But you can also adjust the probability of the balls bouncing right or left when it hits a peg to be something other than 50-50.


Click the SETUP to set up the rows of the triangle, the number of balls, and other parameters. Click to GO button to begin the simulation.

The PILE-UP? button controls if the balls create piles or simply disappear when they reach the bottom of the triangle. If PILE-UP? is on and the pile of balls reaches the bottom of the triangle, the model will stop. Note: if you are running a trial with a large number of balls you might want to turn PILE-UP? off.


With a small number of balls it is hard to notice any consistent patterns in the results.

As you increase the number of balls, clear patterns and distributions start to form. By adjusting the CHANCE-OF-BOUNCING-RIGHT you can see how different factors can change the distribution of balls. What types of distributions form when the CHANCE-OF-BOUNCING-RIGHT is set at 20, 50, or 100?

This model is a good example of an independent trials process. Each ball has a probability of falling one way, and its decision is unrelated to that of any of the other balls. The number of rows the balls must fall through affects the amount of variation present in a run of the model.


Change the NUMBER-OF-BALLS and NUMBER-OF-ROWS sliders. How does varying numbers alter how balls stack up?

Change the CHANCE-OF-BOUNCING-RIGHT slider as balls have begun to fall. What kinds of ball distributions can you produce?

Change the NUMBER-OF-BALLS slider. What is the best way to produce a standard binomial distribution (or approximate a bell curve)?

Set a CHANCE-OF-BOUNCING-RIGHT then try to predict the resulting stacks of balls. How would you calculate the mean and variances of a given stack for a given setting?


Make the balls shade the patches as they fall, so the more balls pass a patch the lighter it gets. This will let the user how frequently different paths are traveled.

Modify the program to allow independent adjustment of each peg, so that they can adjust their own orientation, rather than having all the pegs synchronized.

Change the shape of the board. Maybe flip the triangle upside down. How does this effect how the balls get distributed?

In addition to changing the shape of the board, change the direction balls can go. Maybe allow balls to go in all directions.

Make it so you can select a specific peg. If a ball bounces off that peg, stop the ball. Keep track of how many balls are stopped. What specific insight does this provide about the independent trials process and ball distributions?.


  • Random Walk Left Right
  • Binomial Rabbits


If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

  • Wilensky, U. (2002). NetLogo Galton Box model. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
  • Wilensky, U. (1999). NetLogo. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.


Copyright 2002 Uri Wilensky.


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at

This model was created as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227.

Comments and Questions

Click to Run Model

globals [
  balls        ;; how many balls have been created
  counters     ;; agentset of patches where ball counts are displayed

;; We use two breeds of turtle: one for balls which are still falling,
;; and second for balls which have landed in piles.
breed [falling-balls falling-ball]
breed [piled-balls piled-ball]


to setup
  set-default-shape turtles "circle"
  set balls 0
  ask patch 0 (max-pycor - 2) [
    sprout 1 [ propagate ]
  set counters patches with [counter?]
  ask counters [
    set plabel 0
    set pcolor green - 3
    ;; make the column numbers at the bottom
    ask patch pxcor min-pycor [
      set plabel round (abs pxcor / 2)

;; The way we make the pegs is a bit tricky.  We use turtles,
;; starting with one turtle at the top.  Each turtle colors
;; the patch yellow, then creates two more turtles, one below
;; and left, one below and right.  The parent dies, and the
;; the cycle continues until the last row has been made.
;; This procedure is recursive.

to propagate  ;; peg procedure
  if ycor < max-pycor - 2 - 2 * number-of-rows [ die ]
  set pcolor yellow
  set ycor ycor - 2
  hatch 1 [
    set xcor xcor - 1
  hatch 1 [
    set xcor xcor + 1

to-report counter?  ;; patch procedure
  report (yellow-at? 1 2 or yellow-at? -1 2)
    and not yellow-at? -2 0
    and not yellow-at? 2 0

to-report yellow-at? [x-offset y-offset] ;; patch procedure
  let p patch-at x-offset y-offset
  report p != nobody and [pcolor] of p = yellow


to go
  if time-for-new-ball? [ new-ball ]
  if full? [
    ask falling-balls with [ycor > [pycor] of one-of counters] [
      set balls balls - 1
  if not any? falling-balls [ stop ]
  ask falling-balls [ fall ]
  ask falling-balls-on counters [
    set plabel plabel + 1
    if not pile-up? [ die ]

to fall  ;; falling-balls procedure
  ifelse [pcolor] of patch-at 0 -1 = yellow
  ;; if peg below, go left or right
  [ ifelse random-float 100 < chance-of-bouncing-right
      [ set xcor xcor + 1 ]
      [ set xcor xcor - 1 ]
  ;; if no peg below, go down
  [ set ycor ycor - 1
    if done-falling? [
      set breed piled-balls

to-report done-falling?  ;; falling-ball procedure
  report ycor = (min-pycor + 1)
         or any? piled-balls-on patch-at 0 -1

to new-ball
  ask patch 0 max-pycor [
    sprout-falling-balls 1 [
      set color red
  set balls balls + 1

to-report time-for-new-ball?
  ;; we release a ball every other tick; keeping space
  ;; between the balls makes it easier to ensure that two
  ;; balls never simultaneously occupy the same patch
  report balls < number-of-balls
         and not any? falling-balls-on patch 0 (max-pycor - 1)

to-report full?
  report any? counters with [any? piled-balls-on patch-at 0 -1]

; Copyright 2002 Uri Wilensky.
; See Info tab for full copyright and license.

There are 10 versions of this model.

Uploaded by When Description Download
Uri Wilensky about 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky over 11 years ago Updated version tag Download this version
Uri Wilensky over 11 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 12 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky almost 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 14 years ago Model from NetLogo distribution Download this version
Uri Wilensky almost 14 years ago Galton Box Download this version

Attached files

File Type Description Last updated
Galton Box.png preview Preview for 'Galton Box' about 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.