"H. Peter Anvin" <hpa@xxxxxxxxx> writes: > Christian Couder wrote: >> On Thu, Jun 11, 2009 at 7:05 AM, H. Peter Anvin<hpa@xxxxxxxxx> wrote: >> To implement the PRNG, I guess that using something based on the >> function given by "man 3 rand" should be ok: >> >> int get_prn(int count) { >> count = count * 1103515245 + 12345; >> return((unsigned)(count/65536) % 32768); >> } >> >> where the "count" we pass is the count of elements in the list rather >> than the static seed. > > Yes, or perhaps better we could use some combination of the SHA-1s > involved as seeds... they are rather nice for this as they are wide and > much better PRNGs than most classical algorithms. > > The main problem with the above algorithm is that it only produces 16 > bits of output, which when biased can turn into a fairly significant > granularity. Why not borrow one of algorithms, e.g. taus[1] from GSL (GNU Scientific Library)? If I understand "Random Number Generator Performance" chapter in GSL Manual it is of comparable performance of the above BSD `rand` generator, and is of simulation quality. [1] maximally equidistributed combined Tausworthe generator by L'Ecuyer -- Jakub Narebski Poland ShadeHawk on #git -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html