You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 = newSplFixedArray($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.
The text was updated successfully, but these errors were encountered:
gburtini
changed the title
Abstract testing strategy.
Abstract simulation testing strategy.
Mar 15, 2016
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.
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.
The text was updated successfully, but these errors were encountered: