Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Staff
Combinations and permutations calculator: A tasty new add-in

One of the great new pleasures in life, if you enjoy crunchy chocolate, is pretzel M&Ms. If you haven’t tried then yet, you should!

I’m down to my last five – one of each color (red, blue, brown, green and orange.)  Should I eat just a couple and save the others for later, or eat them all one at a time?

This gets me thinking of all of the possible ways I can eat the M&Ms. If I eat just two, which colors should I choose?  Do I start with the red and then eat the blue? What if I close my eyes and randomly select the two M&Ms? How many possible choices can I make?

Thinking back to the days when I took undergraduate probability and statistics, I recall the discussion of combinations and permutations. If I select two candies and order doesn’t matter, then I’m interested in the number of combinations. In other words, selecting a red first and then a blue counts the same as selecting a blue and then a red – it's still just one combination.

However, if I select two candies (without replacement) and order is important, then that’s a permutation. So, selecting a red first and then a blue is one outcome, and selecting a blue and then a red is another outcome.

Good thing Mark Bailey, a JMP education specialist, has written an application to do the math for us. It turns out we have a lot of choices! There are 10 possible pairs of M&Ms I can select from the five. And, if I’m interested in order, there are 20 possible outcomes, or permutations.

What if I can’t resist and decide to eat all five? How many combinations and permutations are there? There is just one combination, since all five will be eaten. But, there are 120 permutations – 120 possible orders in which I can enjoy eating my last five M&Ms!

Hmm, I’m getting hungry!

The Combinations and Permutations application is available as an add-in on the JMP File Exchange (requires a SAS profile to download) or from the Academic Resources page.

Article Labels

There are no labels assigned to this post.

Article Tags
Visitor

Teresa Obis wrote:

Mia, thanks for this very easy to understand explanation about combinations and permutation. It will be very useful. You have to put it at the One-page Guides.

And Mark, than you for the add-in calculator.

The only problem is at the end of the reading. I would like to try the experiment eating M&Ms, so I miss the M&Ms jar you have at the training room on SAS World Headquarters in Cary.

Also I miss a webcast about applications. This is a very important feature of JMP 10, I would like to learn how to do it. It is a pity I can not join you at JMP Discovery Summit.

Level IV

I see that the addin uses the function "N Choose K(N.K)". However, I cannot find this function documented anywhere. How did you find it? I have been looking for it for quite some time.

Does anyone know why it is not included in the "Discrete Probability" menu in the Formula editor? It seems like an odd omission.

Staff

Jesper, the functions that I use are documented in the books and the index. For example, select Help > Scripting Index. Then click the button at the top left and select Functions. Type choose in the search box and press Enter. A short list of results includes N Choose K(). Select this function to see the information about it on the right side.

Level IV

Thank you :)

Level IV

Wow, thank you for the N Choose K Matrix function! In writing a script to evaluate site or sample reduction, this function made it very easy. From a matrix that has all the raw data of say original 13 samples, it was easy to use the matrices to show all possible combinations at 9, 8, 7, 6, and 5, and calculate the R-square of the reduced sample to the original data, and satisfy all questions from the end customers in metrology. There were many examples of how to code this yourself in other software at Rosetta Code: https://rosettacode.org/wiki/Permutations. I was wondering why no reference to JSL, because it was already there! So not only how many permutations from NChooseK, but the more important NChooseK Matrix made scripting this very easy.

For N Choose K Matrix(9,5), easy to compare [1 2 3 4 5] samples all the way up to [5 6 7 8 9], 126 permutations.