Probability+-+Quincunx+Explained

=Quincunx Explained= Balls are dropped onto the top peg and then bounce their way down to the bottom where they are collected in little bins. Each time a ball hits one of the pegs, it bounces either left or right. ||
 * [[image:http://www.mathsisfun.com/data/images/quincunx.jpg width="129" height="172"]] || A [|Quincunx] or "Galton Board" (named after Sir Francis Galton) is a triangular array of pegs.


 * But this is interesting: if there is an equal chance of bouncing left or right, then the pegs collecting in the bins form the classic "bell-shaped" curve of the [|normal distribution].

(If the probabilities are not even, you still get a nice "//skewed"// version of the normal distribution.) || ||

Formula
You can actually calculate the probabilities!
 * [[image:http://www.mathsisfun.com/data/images/quincunx-left-2.jpg width="226" height="247"]] || || Think about this: a ball would end up in the bin **k** places from the //right// if it has taken **k** //left// turns. ||
 * In this example, the ball has taken two bounces to the left, and all other bounces were to the right. It ended up in the bin two places from the right. ||
 * In the general case, if the quincunx has **n** rows then a possible path for the ball would be **k** bounces to the left and **(n-k)** bounces to the right. ||
 * And if the probability of bouncing to the left is **p** then we can calculate the probability of a certain path like this: || ||
 * In the general case, if the quincunx has **n** rows then a possible path for the ball would be **k** bounces to the left and **(n-k)** bounces to the right. ||
 * And if the probability of bouncing to the left is **p** then we can calculate the probability of a certain path like this: || ||
 * And if the probability of bouncing to the left is **p** then we can calculate the probability of a certain path like this: || ||

You could list all such paths (LLRRR.., LRLRR..., LRRL...), but there are two easier ways.
 * || [[image:http://www.mathsisfun.com/images/style/left-arrow.gif width="46" height="46"]] || The ball bounces **k** times to the left with a probability of **p**: **pk** ||
 * || [[image:http://www.mathsisfun.com/images/style/right-arrow.gif width="46" height="46"]] || And the other bounces **(n-k)** have the opposite probability of: **(1-p)(n-k)** ||
 * || [[image:http://www.mathsisfun.com/images/style/star.gif width="45" height="43"]] || So, the probability of following such a path is **pk(1-p)(n-k)** ||
 * But there could be many such paths!** For example the left turns could be the 1st and 2nd, or 1st and 3rd, or 2nd and 7th, etc.
 * But there could be many such paths!** For example the left turns could be the 1st and 2nd, or 1st and 3rd, or 2nd and 7th, etc.

How Many Paths
You can look at [|Pascal's Triangle]. In fact, the Quincunx is just like Pascal's Triangle, with pegs instead of numbers. The number on each peg shows you how many different paths can be taken to get to that peg. Amazing but true. Or you can use this formula from the subject of [|Combinations]:
 * || [[image:http://www.mathsisfun.com/data/images/binomial-n-choose-k.png width="152" height="53"]] ||  || This is commonly called "n choose k" and written C(n,k).

It is the calculation of the number of ways of distributing k things in a sequence of n. || Putting it all together, the resulting formula is:
 * ||  ||   || (The "!" means "[|factorial]", for example 4! = 1×2×3×4 = 24) ||
 * ||  ||   || (The "!" means "[|factorial]", for example 4! = 1×2×3×4 = 24) ||

(Which, by the way, is the formula for the binomial distribution.)

Example:
For 10 rows //(n=10)// and probability of bouncing left of 0.5 //(p=0.5)//, we can calculate the probability of being in the 3rd bin from the right //(k=3)// as:

//also://

(This means there are 120 different paths that would end

up with the ball in the 3rd bin from the right.) //So we get://

In fact we can build a whole table for rows=10 and probability=0.5 like this:
 * ~ From Right: || 10 || 9 || 8 || 7 || 6 || 5 || 4 || 3 || 2 || 1 || 0 ||
 * ~ Probability: || 0.001 || 0.010 || 0.044 || 0.117 || 0.205 || 0.246 || 0.205 || 0.117 || 0.044 || 0.010 || 0.001 ||
 * ~ Example: 100 balls || 0 || 1 || 4 || 12 || 21 || 24 || 21 || 12 || 4 || 1 || 0 ||

Now, of course, this is a random thing so your results may vary from this ideal situation.

Another Example:
If the probability were 0.8 then the table would look like this:
 * ~ From Right || 10 || 9 || 8 || 7 || 6 || 5 || 4 || 3 || 2 || 1 || 0 ||
 * ~ Probability || 0.107 || 0.268 || 0.302 || 0.201 || 0.088 || 0.026 || 0.006 || 0.001 || 0.000 || 0.000 || 0.000 ||
 * ~ Example: 100 balls || 11 || 26 || 30 || 20 || 9 || 3 || 1 || 0 || 0 || 0 || 0 ||

Try It Yourself
Run 100 (or more) balls through the Quincunx and see what results you get. I have done this many times myself while developing the software. I never got the perfect result, but always something surprisingly close. Good Luck!

=Reference=

@http://www.mathsisfun.com