Re: Testing a class which utilizes randomness

Steven Gordon <[email protected]> Fri, 4 Apr 2014 11:48:58 -0700
Newsgroups gmane.comp.programming.test-driven-development
Message-ID <CAF7qo6Vsjc0b66gc_bALvdW5VgCoboR65ZP1F3cAx9XcnDNwHg@mail.gmail.com>
This project is presumably using an RNG rather than coding one.

The criteria that matters would be whether the strings being generated
(using an RNG) is sufficiently random, not whether the sequence of numbers
that are being used to generate those strings are sufficiently random.

It is quite possible for the RNG to be random enough, but the strings to
not be.  For example, the long term behavior of the random number generator
could always create a nice random distribution on bins, but that
subsequences are not as random. If each string would be created by a
subsequence rather than individual number, then they would not be random
enough.

It could make a difference whether or not the size of the character set is
prime.


On Fri, Apr 4, 2014 at 11:36 AM, Ron Jeffries <[email protected]> wrote:

>
>
> Jarod,
>
> On Apr 4, 2014, at 1:55 PM, Jarod Eells <[email protected]> wrote:
>
> 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.
>
>
> I'd advise a little research on this topic. There are issues of runs,
> alternation, patterns, and many others. It's quite a subject.
>
> Ron Jeffries
> www.XProgramming.com
> Sometimes I give myself admirable advice, but I am incapable of taking it.
> -- Mary Wortley Montagu
>
>
>
>  
>