Is there an easy known bijective mapping formula between the set $\{1,\ldots,n!\}$ and the symmetric group $S_n$? I want to pick a number $k \in \{1,\ldots ,n!\}$ and assign a unique permutation of $(1,\ldots, n)$ to it.
Numbering the transpositions generating $S_n$ doesn't help, since they can occur multiple times and don't commute. Maybe the permutation matrices (in every column and row exactly one 1 and 0 elsewhere) could give a hint, but I don't see the solution.
Context: I want to simulate a certain probability distribution on the symmetric group. It's easy to pick random integer numbers. So easy mapping a random number to a permutation is left.
Yes there is an easy and well known such bijection, although as happens so often (that I don't understand why people don't just get into the habit) it becomes easier if one starts counting at $0$, so that one is looking for a bijection between permutations of the set $[n]=\{\,i\in\Bbb Z \mid 0\leq i<n\,\}$ and the (similar) set $[n!]$. Using the factorial number system, a number of the latter set is represented as an $n$-tuple $[d_n,\ldots,d_1]$ with $d_i\in[i]$ (as is conventional the least significant digit it as the right), and this sequence can be mapped to a permutation using the Lehmer code. Both conversions are straightforward and easily computed in both directions, and combining them numbers the permutations in lexicographic ordering. Nonetheless the one between a permutation and its Lehmer code not quite as easily computed as one should like (it is not even $O(n\lg n)$ using any obvious data structure), which makes use of this mapping loose out against direct methods when it comes to efficient enumeration of permutations in lexicographic order. However, it would still be a method of choice if you want to store information about permutations in a tight linear array, and need to be able to look up the information associated to a given permutation rapidly.