# Function Repository Resource:

# GaltonBoardModel

Model ball trajectories in a 2D Galton board using Hertzian force laws between the ball and the pegs

Contributed by: Michael Trott
 ResourceFunction["GaltonBoardModel"][brd,inits, output] models the dynamics in a Galton board brd with ball initial conditions inits and returns the model result output as the graphic or data. ResourceFunction["GaltonBoardModel"][brd,prop] computes the property prop of the Galton board brd. ResourceFunction["GaltonBoardModel"]["RandomGaltonBoard"] returns a random Galton board.

## Details and Options

A Galton board board is specified as an association with the following keys specifying the pegs, the rows of pegs and the ball parameters (all assumed to be dimensionless numbers):
 "RowCount" number of rows of pegs "PegRadius" radius of the pegs "PegHardness" hardness of the pegs "PegForceExponent" exponent of the force law "PegRotation" rotation of the peg deformation from the radial direction "VerticalAcceleration" vertical acceleration "LinearFrictionCoefficient" friction force on the balls proportional to their speed "QuadraticFrictionCoefficient" friction force on the balls proportional to their speed squared "BallRadius" radius of the balls
WLOG, the position of the center of the single peg of the first row, is assumed to be {0,0}. The vertical spacing between rows is fixed to be 1.
For small deformations, the force law is assumed to be of elastic Hertzian form force~deformationα, where α is the exponent of the force law of the peg-ball interaction. (The sphere-sphere force law is α=3/2, and the cylinder-cylinder force law with aligned axis is α=1.) For large deformations, the force law smoothly approaches a maximum value.
The model numerically solves the Newtonian equations of motion for the balls until a ball reaches one unit below the last row of pegs.
Each ball is assumed to move through the Galton board individually; no ball-ball interactions are included.
The ball radius can be 0.
The initial conditions are lists, and each element can be of the following form:
 xi assume y=1 and {vx,i,vy,i}={0,0} {xi,yi} assume {vx,vy}={0,0} {{xi,yi},{vx,i,vy,i}} fully specified initial conditions
The following output types output can be specified:
 "PathGraphics" a graphic of the pegs and ball paths "PathGraphics3D" a 3D graphic of the pegs and ball paths with the ball velocities as the z values "Paths" list of paths as styled line primitives "FinalPosition" a list of the positions of the balls one unit down from the last row of pegs "PathArcLengths" a list of the arc lengths of the ball paths "ArrivalTimes" a list of the arrival times of the ball paths "InterpolatingFunctions" a list of pairs of {position,velocity} interpolating functions of the ball paths {"PathArrayPlot", dim} an array plot of dimension dim×dim of the ball path "TimeEvolution" an interactive demonstration allowing you to step through the ball-falling process "Manipulate" an interactive demonstration allowing you to change board parameters and ball initial positions
For the "Manipulate" output type, at least one of the parameter values or initial conditions must be an interval.
The following options can be specified:
 "TrajectoryStyle" {blue,white} color directive for the ball paths "PegStyle" slightly opaque dark red pair of center-boundary colors of the pegs
The local color of a peg is a blend of the two "TrajectorStyle" colors, with the blending ratio according to the Hertzian force.
The following properties prop are supported for boards:
 "TotalPegCount" the total count of pegs "MinPegDistance" the minimum distance between two pegs "PegPositions" a list of the center corrdinates of the pegs "ForceLawSketch" sketch of the specified Hertzian force law

## Examples

### Basic Examples (5)

A single ball path in a large Galton board of 60 rows of pegs:

 In:= Out= The ball paths for a typically sized Galton board using a realistic force law and finite-sized balls:

 In:= Out= Point-size balls, no friction lead and a small friction coefficient:

 In:= Out= Large, soft pegs allow particles to substantially penetrate and deform the pegs:

 In:= Out= Sketch of the force law of α=1/2 and hardness 12 of a peg:

 In:= Out= The force law for α=4:

 In:= Out= ### Scope (2)

Use nonvanishing initial velocities for the balls (all originating from a single point):

 In:= Out= A list of result types returns an association of results:

 In:= Out= #### PathSpeedGraphics3D (1)

Show the speed of the balls as the vertical function value:

 In:= Out= #### PathArrayPlot (1)

Displaying many (tens of thousands or even hundreds of thousands) of paths would result in large graphics with many ball paths. Returning the result as an array plot is much more memory efficient:

 In:= Out= #### TimeEvolution (1)

Return an interactive demonstration/animation showing the time-dependent paths of the balls:

 In:= Out= #### Manipulate (2)

Interactively explore the ball paths as a function of some of the board parameters:

 In:= Out= Also include the initial conditions in the interactive controls:

 In:= Out= #### ArrivalTimes (4)

The ball paths in a relatively bouncy set of pegs:

 In:= Out= Compute the arrival (at the imaginary row 25) for 1,000 balls:

 In:= Plot the histogram of the distribution of the arrival times:

 In:= Out= Fit with a typical first-hit distribution for Brownian motion with drift:

 In:= Out= In:= Out= #### InterpolatingFunctions (3)

In modeling the result for a Galton board with large pegs, many balls never penetrate the interior regions between the pegs:

 In:= Out= Obtain the interpolating functions for the positions and velocities for 10 paths:

 In:= Out= Show the speed versus the vertical coordinate for all paths:

 In:= Out= ### Options (2)

Specify yellow pegs and blue ball paths:

 In:= Out= To visualize a finite ball size, specify in the "TrajectoryStyle" option setting to obtain "thick" ball paths:

 In:= Out= ### Applications (2)

Show regression to the center for a board:

 In:= The balls' paths:

 In:= Out= The final positions of the balls:

 In:= Out= Bin the data under the last row of pegs:

 In:= Show a histogram of the binned data:

 In:= Out= Fit the final positions to a normal distribution:

 In:= Out= Because of the binning, a direct test fails:

 In:= Out= Use bootstrapping and collect statistics:

 In:= Compute the p-value:

 In:= Out= Compute the autocorrelation function for the ball position.

Start the balls from deep within the board:

 In:= Out= Get the interpolating functions of the ball paths:

 In:= Define the position autocorrelation function by averaging along each path as well as over all paths:

 In:= In:= Plot c(τ) as a function of τ:

 In:= Out= Fit c(τ) to a power law c(τ)~τβ; the value β≲0.5 indicates subdiffusive movement:

 In:= Out= ### Properties and Relations (1)

Very small vertical acceleration turns the Galton board into a classical Lorenz gas:

 In:= Out= ### Possible Issues (1)

Negative friction coefficients (modeling autonomous balls) and rotating peg forces (modeling rotating pegs) can lead to unusual path shapes:

 In:= Out= ### Neat Examples (3)

Inject balls with slightly different initial conditions to see the trajectories diverge after multiple peg collisions:

 In:= In:= Out= Retrieve some "random" boards with preselected parameters:

 In:= Out= In:= Out= In:= Out= Connect ball trajectories and form an intricate polygon:

 In:= In:= In:= Out= ## Version History

• 2.0.0 – 11 January 2021