Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Tuesday September 19, 2006
05:19 AM

Testing Random Functions

[ #31048 ]

They're not just any random functions. They're random functions with bugs. Testing this is always fun.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Random functions require random tests, of course.

    Just like documentation: if it was hard to write, it should be hard to read.

  • Tests of random functions, that is to say functions specified to act randomly, must be STATISTICAL tests. Run the function a large number of times ($N), and check that the basic and not-so-basic statistics match the model you require of your function under test.

    Pseudo code for an inadequate number of tests of an imaginary model, assumed not unlike a bell-curve - your mileage WILL vary -

    $fut= \&FunctionUnderTest;
    my @X= map { $fut->() } 1..$N ;

    use Acme::Statistics; # Fantasy package that provides

    --
    Bill
    # I had a sig when sigs were cool
    use Sig;
    • Interesting. I was just talking to a coworker about that. It's been years since statistics classes and I was struggling to remember the formulae involved in calculating what I was interested in. I wasn't thinking of a distribution under a bell curve so much as I was thinking "if X might not be correct, how many times do I need to calculate X to ensure the odds of it being incorrect are acceptably minimized?" More inportantly, I can't have randomly failing tests, but I'm quite happy to have a test which

  • Intelligently designed!