Re: Testing a class which utilizes randomness
Michael Hill <[email protected]> Fri, 4 Apr 2014 23:21:40 -0400
| Newsgroups | gmane.comp.programming.test-driven-development |
|---|---|
| Message-ID | <CAOGuBf=bQuZjkdRLwQRS5LqP11FTGuc7mgNF_xKbYMmfOgid_Q@mail.gmail.com> |
jarod... actually, to validate a PRNG is a very complex piece of sophisticated statistical analysis. as an example, let's take your observation. the numbers 1,2,3,4...n, served in that order, will certainly pass your proposed bin for any number of bins that's a divisor of n. try knuth, volume 2, which dedicates over a third of its text to PRNG algorithms and their analyses. (a long and entirely irrelevant aside, cuz i've always been fascinated with this stuff: if you have knuth, check out his algorithm A, p. 27. this is an extremely fast (addition only) algorithm. curiously, I've never seen an analysis of algorithm A that rejects it. but I have seen that virtually *all* of the people who give their lives over to such things consistently choose far more complex algorithms, and i'm betting they have their reasons. i've used it several times, but because i needed very long cycles. most default language libraries have PRNGs with cycles in the low thousands, which is pathetic. algorithm A is 2^54th periodicity. if anyone knows of a serious analysis of A, i'd love to see it. if a person wanted high-grade PRNG they'd need to research the alternatives and pick a serious one. actual cryptologists use hardware RNG's rather than algorithms. time periods between alpha particle reception is one way, and there are others.) seeya, hill On Fri, Apr 4, 2014 at 1:55 PM, Jarod Eells <[email protected]> wrote: > > > On Fri, Apr 04, 2014 at 12:23:49PM -0400, Mark Levison wrote: > > Desirable? - by definition - randomness can and should occasionally > > duplicate something. Testing a random number generator is very hard. > > > > Cheers > > Mark > > Testing a RNG doesn't have to be hard. > Just have to roll the dice a sufficient number of times and bin out the > results. > Then check that the bins are filled according to the expected statistical > distribution. > If you want a higher accuracy for your test then make more bins and/or > roll more numbers. > > Jarod Eells > >