Well for one thing if your rng is very good you can use a single 32- bit integer to generate 16 numbers in [0..3].
On Dec 7, 11:08 am, pfb <pf.buonsa...@gmail.com> wrote: > Hi all, > > I have a question about pseudo random number generation. > > My code currently employs a standard pseudo random number generator > developed by Knuth, > which is basically a black box to me. Since > > 1) My code spends most of the time generating the random integers it > needs. > 2) Most of the times i simply need a pseudo random integer (PRI) > between 0 and 3. > > I was wondering whether I can take advantage of the reduced size of > the set of my random numbers (4). > > I mean: does the set size matter? Would it be worth programming an > algorithm specifically devoted to > randomly choosing one number out of the set {0,1,2,3}? Would this > algorithm be much faster than > a general purpose algorithm? > > What kind of algorithm would you suggest? > > Thanks a lot in advance > > Francesco -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.