Wolfram Function Repository
Instantuse addon functions for the Wolfram Language
Function Repository Resource:
Model ball trajectories in a 2D Galton board using Hertzian force laws between the ball and the pegs
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. 
"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 
x_{i}  assume y=1 and {v_{x,i},v_{y,i}}={0,0} 
{x_{i},y_{i}}  assume {v_{x},v_{y}}={0,0} 
{{x_{i},y_{i}},{v_{x,i},v_{y,i}}}  fully specified initial conditions 
"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 ballfalling process 
"Manipulate"  an interactive demonstration allowing you to change board parameters and ball initial positions 
"TrajectoryStyle"  {blue,white}  color directive for the ball paths 
"PegStyle"  slightly opaque dark red  pair of centerboundary colors of the pegs 
"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 
A single ball path in a large Galton board of 60 rows of pegs:
In[1]:= 

Out[2]= 

The ball paths for a typically sized Galton board using a realistic force law and finitesized balls:
In[3]:= 

Out[3]= 

Pointsize balls, no friction lead and a small friction coefficient:
In[4]:= 

Out[4]= 

Large, soft pegs allow particles to substantially penetrate and deform the pegs:
In[5]:= 

Out[5]= 

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

Out[6]= 

The force law for α=4:
In[7]:= 

Out[7]= 

Use nonvanishing initial velocities for the balls (all originating from a single point):
In[8]:= 

Out[8]= 

A list of result types returns an association of results:
In[9]:= 

Out[10]= 

Show the speed of the balls as the vertical function value:
In[11]:= 

Out[11]= 

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[12]:= 

Out[12]= 

Return an interactive demonstration/animation showing the timedependent paths of the balls:
In[13]:= 

Out[13]= 

Interactively explore the ball paths as a function of some of the board parameters:
In[14]:= 

Out[14]= 

Also include the initial conditions in the interactive controls:
In[15]:= 

Out[15]= 

The ball paths in a relatively bouncy set of pegs:
In[16]:= 

Out[17]= 

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

Plot the histogram of the distribution of the arrival times:
In[19]:= 

Out[19]= 

Fit with a typical firsthit distribution for Brownian motion with drift:
In[20]:= 

Out[21]= 

In[22]:= 

Out[22]= 

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

Out[24]= 

Obtain the interpolating functions for the positions and velocities for 10 paths:
In[25]:= 

Out[26]= 

Show the speed versus the vertical coordinate for all paths:
In[27]:= 

Out[27]= 

Specify yellow pegs and blue ball paths:
In[28]:= 

Out[28]= 

To visualize a finite ball size, specify Thickness[Automatic] in the "TrajectoryStyle" option setting to obtain "thick" ball paths:
In[29]:= 

Out[29]= 

Show regression to the center for a board:
In[30]:= 

The balls' paths:
In[31]:= 

Out[31]= 

The final positions of the balls:
In[32]:= 

Out[32]= 

Bin the data under the last row of pegs:
In[33]:= 

Show a histogram of the binned data:
In[34]:= 

Out[34]= 

Fit the final positions to a normal distribution:
In[35]:= 

Out[35]= 

Because of the binning, a direct test fails:
In[36]:= 

Out[36]= 

Use bootstrapping and collect statistics:
In[37]:= 

Compute the pvalue:
In[38]:= 

Out[38]= 

Compute the autocorrelation function for the ball position.
Start the balls from deep within the board:
In[39]:= 

Out[39]= 

Get the interpolating functions of the ball paths:
In[40]:= 

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

In[42]:= 

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

Out[43]= 

Fit c(τ) to a power law c(τ)~τ^{β}; the value β≲0.5 indicates subdiffusive movement:
In[44]:= 

Out[44]= 

Very small vertical acceleration turns the Galton board into a classical Lorenz gas:
In[45]:= 

Out[45]= 

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

Out[46]= 

Inject balls with slightly different initial conditions to see the trajectories diverge after multiple peg collisions:
In[47]:= 

In[48]:= 

Out[48]= 

Retrieve some "random" boards with preselected parameters:
In[49]:= 

Out[49]= 

In[50]:= 

Out[50]= 

In[51]:= 

Out[51]= 

Connect ball trajectories and form an intricate polygon:
In[52]:= 

In[53]:= 

In[54]:= 

Out[54]= 

This work is licensed under a Creative Commons Attribution 4.0 International License