2

I have looked into the Knuth collection shuffle algorithm with pseudorandom number generators. They say that a PRNG with a seed state of $19937$ bits (like one of the Mersenne Twisters) can shuffle a collection up to $2080$ with equal probability.

I made the calculations. Given a list of $2080$ elements, I calculated that I needed at least:

$$ \lceil \log_2 2080! \rceil $$

bits in the seed state to be able to shuffle the list with a chance of getting any possible combination. (it yields $19933$)

I'd like to reverse this function. That is, given a PRNG with $n$ bits of seed, what is the maximum size of the list I can shuffle without the PRN cycle being to short to encode all possible combinations of the sequence? Is there another way than setting up a table of the factorials and perform a lookup?

  • Given $n$ you can compute $2^n$ and then divide by consecutive integers until the result is less than $1$. – Servaes Jun 05 '14 at 11:51
  • Nice, more efficient. But is there a reciprocal to the factorial ? – Laurent LA RIZZA Jun 05 '14 at 12:12
  • That question has been asked before, but unfortunately there is no straightforward answer. It depends on what input you allow for the factorial, and what kind of solutions you are looking for precisely. Perhaps one of these will give you a satisfactory answer:

    http://math.stackexchange.com/questions/61755/is-there-a-way-to-solve-for-an-unknown-in-a-factorial http://math.stackexchange.com/questions/18362/is-there-an-inverse-gamma-gamma-1-z-function

    – Servaes Jun 05 '14 at 12:29
  • Stirling's approximation might come in handy, together with the various properties of the logarithm. – Lucian Jun 05 '14 at 12:54
  • This could evolve into a really good cryptographic function (though it definitely isn't yet)! – asher drummond Jun 01 '16 at 02:24

0 Answers0