In the mathematics of permutations and the study of shuffling playing cards, a riffle shuffle permutation is one of the permutations of a set of formula_1 items that can be obtained by a single riffle shuffle, in which a sorted deck of formula_1 cards is cut into two packets and then the two packets are interleaved (e.g. by moving cards one at a time from the bottom of one or the other of the packets to the top of the sorted deck). Beginning with an ordered set (1 rising sequence), mathematically a riffle shuffle is defined as a permutation on this set containing 1 or 2 rising sequences. The permutations with 1 rising sequence are the identity permutations.
As a special case of this, a formula_3-shuffle, for numbers formula_4 and formula_5 with formula_6, is a riffle in which the first packet has formula_4 cards and the second packet has formula_5 cards.
Combinatorial enumeration.
Since a formula_3-shuffle is completely determined by how its first formula_4 elements are mapped, the number of formula_3-shuffles is
formula_12
However, the number of distinct riffles is not quite the sum of this formula over all choices of formula_4 and formula_5 adding to formula_1 (which would be formula_16), because the identity permutation can be represented in multiple ways as a formula_3-shuffle for different values of formula_4 and formula_5.
Instead, the number of distinct riffle shuffle permutations of a deck of formula_1 cards, for formula_21, is
 ;templatestyles src="Block indent/styles.css"/ ;
More generally, the formula for this number is formula_22; for instance, there are 4503599627370444 riffle shuffle permutations of a 52-card deck.
The number of permutations that are both a riffle shuffle permutation and the inverse permutation of a riffle shuffle is
formula_23
For formula_21, this is
 ;templatestyles src="Block indent/styles.css"/ ;
and for formula_25 there are exactly 23427 invertible shuffles.
Random distribution.
The Gilbert–Shannon–Reeds model describes a random probability distribution on riffle shuffles that is a good match for observed human shuffles. In this model, the identity permutation has probability formula_26 of being generated, and all other riffle permutations have equal probability formula_27 of being generated. Based on their analysis of this model, mathematicians have recommended that a deck of 52 cards be given seven riffles in order to thoroughly randomize it.
Permutation patterns.
A pattern in a permutation is a smaller permutation formed from a subsequence of some formula_28 values in the permutation by reducing these values to the range from 1 to formula_28 while preserving their order. Several important families of permutations can be characterized by a finite set of forbidden patterns, and this is true also of the riffle shuffle permutations: they are exactly the permutations that do not have 321, 2143, and 2413 as patterns. Thus, for instance, they are a subclass of the vexillary permutations, which have 2143 as their only minimal forbidden pattern.
Perfect shuffles.
A "perfect shuffle" is a riffle in which the deck is split into two equal-sized packets, and in which the interleaving between these two packets strictly alternates between the two. There are two types of perfect shuffle, an in shuffle and an out shuffle, both of which can be performed consistently by some well-trained people. When a deck is repeatedly shuffled using these permutations, it remains much less random than with typical riffle shuffles, and it will return to its initial state after only a small number of perfect shuffles. In particular, a deck of 52 playing cards will be returned to its original ordering after 52 in shuffles or 8 out shuffles. This fact forms the basis of several magic tricks.
Algebra.
Riffle shuffles may be used to define the shuffle algebra. This is a Hopf algebra where the basis is a set of words,
and the product is the shuffle product denoted by the sha symbol ш, the sum of all riffle shuffles of two words.
In exterior algebra, the wedge product of a formula_4-form and a formula_5-form can be defined as a sum over formula_3-shuffles.
References.
 ;templatestyles src="Reflist/styles.css" / ;