Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract simulation testing strategy. #10

Open
gburtini opened this issue Mar 15, 2016 · 1 comment
Open

Abstract simulation testing strategy. #10

gburtini opened this issue Mar 15, 2016 · 1 comment

Comments

@gburtini
Copy link
Owner

When testing if an implementation probabilistically fits the expected distribution, we should be able to abstract simulatory code something like this to test probability cutoff and means. We could also compute expected variances and such within a bound.

$scale = 50000;
$cutoff = 10.0;
$counter = 0;
$draws = new SplFixedArray($scale);
for($i = 0; $i < $scale; $i++) {
   $x = $d->rand();
   $draws[$i] = $x;
   if ($x > $cutoff) $counter = $counter + 1;
}
$number = array_sum((array) $draws) / count($draws);
$this->assertEquals( $number,7.0, "Attempting to draw from P(7.0) {$scale} times gives us a value too far from the expected mean. This could be just random chance.", 0.01);

$p = $counter / $scale;
$this->assertEquals(1-$d->cdf($cutoff), $p, "Attempting to draw from P(7.0) {$scale} times gives the wrong number of values greater than {$cutoff}. This could be just random chance.", 0.01);

A single implementation of this sort of testing that can be reused in the tests will have a lot of value in this project. Speed ($scale) is a concern though.

@gburtini gburtini changed the title Abstract testing strategy. Abstract simulation testing strategy. Mar 15, 2016
@gustawdaniel
Copy link
Contributor

These heavy tests should be tagged specially and should be optional. Tests used to development should be light and speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants