next up previous
Next: References

Generating Random Factored Numbers, Easily

Adam Kalai
akalai@cs.cmu.edu

Consider the problem of generating a random ``pre-factored'' number, that is a uniformly random number between 1 and N, along with its prime factorization. In his dissertation, Erich Bach presents an efficient algorithm for this problem [1, 2]. Here, we present a significantly simpler algorithm and analysis for the same problem. Our algorithm is, however, a tex2html_wrap_inline59 factor less efficient.

tex2html_wrap145

The key to understanding this algorithm is that each prime tex2html_wrap_inline81 is included in the sequence independently with probability tex2html_wrap_inline83 . Intuitively, this is because p occurs iff it is chosen before tex2html_wrap_inline87 , which happens with probability tex2html_wrap_inline83 . As a result, the probability of generating a factored number tex2html_wrap_inline91 is proportional to tex2html_wrap_inline93 . Step 3 then makes each number equally likely with rejection sampling.

We could have equivalently, but more slowly, generated the sequence in Step 1 by first choosing the number of occurrences of N, and then generating such a sequence for N-1. This follows from the fact that, regardless of the number of occurrences of N, the first number in the sequence less than N is equally likely to be tex2html_wrap_inline103 . Clearly N occurs at least once with probability tex2html_wrap_inline107 and occurs exactly tex2html_wrap_inline109 times with probability tex2html_wrap_inline111 . It follows, by induction on N, that the probability of having tex2html_wrap_inline115 occurrences of j is tex2html_wrap_inline119 , and that occurrences of different j are independent.

The chance of having tex2html_wrap_inline123 occurrences of each prime tex2html_wrap_inline81 and generating the factored number tex2html_wrap_inline127 in Step 2 is, by independence,

displaymath53

Thus the probability of generating an tex2html_wrap_inline129 and outputting it in Step 3 is tex2html_wrap_inline131 , which means that all tex2html_wrap_inline129 are equally likely. So, with probability tex2html_wrap_inline135 we output a uniformly random factored number, and otherwise we restart. Consequently, the expected number of restarts is tex2html_wrap_inline137 , by Merten's theorem [3]. On a run, we expect to execute tex2html_wrap_inline139 primality tests, giving an expected tex2html_wrap_inline141 primality tests before success. Bach's algorithm uses only an expected tex2html_wrap_inline143 tests. For either algorithm, primality tests can be implemented efficiently by a randomized algorithm.

Acknowledgements. I would like to thank Manuel Blum, Michael Rabin, and Doug Rohde for helpful comments.





next up previous
Next: References



Adam Kalai
Mon Mar 19 17:50:42 EST 2001