DK96-OS / MathTools

Mathematical Software Components. This library is actively maintained, and aims to stay updated. New feature proposals are welcome, but may not be included.
Apache License 2.0
2 stars 1 forks source link

Integer Range Generators #63

Closed DK96-OS closed 2 years ago

DK96-OS commented 2 years ago

Create Integer Range Generators.

Create Integer counters for evaluating the output of generators.

DK96-OS commented 2 years ago

Remaining Goals for PR:

DK96-OS commented 2 years ago

The remaining coverage on IntRangeElement requires validating the behavior of the generate method in cases where the number of possible outputs is very large.

Assuming we are using a true random number source, a large number of values may need to be generated before the values at the ends of the valid range are observed.

This is where the IntCounter127 and the IntCounterTree are important.

IntCounter127 is better than using a boolean, because statistics operations can be applied at the end of the test.

IntCounterTree is helpful for combining multiple IntRangeCounter instances, as these counters have a limit on the size of their internal arrays.

DK96-OS commented 2 years ago

Alternatively, a pseudorandom generator (or mock) could be injected by the test environment, and this could provide the values that are needed to validate IntRangeElement behavior.

DK96-OS commented 2 years ago

IntRangeElement range of 16 values parameterized test case:

It is interesting to note that the StandardDeviation of the counts of generated values seemed to be larger when the range was either near the Integer.MIN or Integer.MAX

For value ranges (0, 15) and (-16, -1) the StandardDeviation was about or less than 11. But for both MIN and MAX cases, the StandardDeviation was about 13 or 7.

This does not look good for randomness utilities if these results can be repeated.

DK96-OS commented 2 years ago

The recent test failure in IntRangeElementGeneratedValuesTest was caused by random fluctuations. The standard deviation of count values was lower than expected, which shows that the generated values were more uniformly distributed than during other runs.

After rerunning tests, it appears there is no discernible pattern, and no dependence on where the range of generated values are located on the Integer domain.

What is not being tested currently, is whether any particular value in any of these target ranges has some distinguishable behavior relative to the other values.