quincunx {derivmkts} | R Documentation |
Quincunx simulation
Description
quincunx
simulates balls dropping down a
pegboard with a 50% chance of bouncing right or left at each
level. The balls accumulate in bins. If enough balls are dropped,
the distribution approaches normality. This device is called a
quincunx. See https://www.mathsisfun.com/data/quincunx.html
Usage
quincunx(n = 3, numballs = 20, delay = 0.1, probright = 0.5, plottrue = TRUE)
Arguments
n |
Integer The number of peg levels, default is 3 |
numballs |
Integer The number of balls dropped, default is 20 |
delay |
Numeric Number of seconds between ball drops. Set
delay > 0 to see animation with |
probright |
Numeric The probability the ball bounces to the right; default is 0.5 |
plottrue |
Boolean If |
Examples
## These examples will not display correctly within RStudio unless
## the plot window is large
quincunx(delay=0)
quincunx(n=10, numballs=200, delay=0)
quincunx(n=20, numballs=200, delay=0, probright=0.7)