Chris McCarthy and Johannes Familton. “Virtual Pascal’s Triangles: The Ballot Problem and the Method of Images.” The Electronic Journal of Mathematics and Technology. Vol 11, No 1 (accepted for publication July 10, 2016, published February 15, 2017). Link to paper.
The supplementary material was originally posted to Math & Simulations, July 9, 2016.
Supplementary Material
Virtual Pascal’s Triangles – R script.
R script file for Virtual Pascal’s Triangles <— Click to download R script file.
The above script (which is a .txt file) contains the R code (for the functions and examples) from the paper Virtual Pascal’s Triangles: The Ballot Problem and the Method of Images (February 2017). The script needs to be run from inside of R. The script has been tested and runs well in R and r-fiddle (see below). Unfortunately, the script does not play nicely with RStudio.
The three examples from the paper which make use of the R script are:
- Example 1. Generate an image of a standard Pascal’s triangle, see Figure 1, below.
- Example 2. Generate an image of a virtual Pascal’s triangle interfering with a standard Pascal’s triangle, see Figure 2, below.
- Example 3. Solve the classic ballot problem using the method of virtual Pascal’s triangles for the case: suppose candidate A received a = 8 votes and candidate B received b = 5 votes. Find the probability that candidate A is always ahead in the vote count.[1] “Probability A always ahead of B = 0.230769230769231”
Links to R
R is a free (open source) software environment for statistical computing and graphics.
R homepage (download R)
www.r-fiddle.org (online version of R, doesn’t need to be downloaded)
Note: after you download the R script, you can paste it into r-fiddle.