USArmy-Corps-of-Engineers-RMC / Numerics

Numerics is a free and open-source library for .NET developed by USACE-RMC, providing a comprehensive set of methods and algorithms for numerical computations and statistical analysis.
Other
20 stars 2 forks source link

Test_Histogram - GetBinIndex() failing on Last Index #64

Closed sadie-niblett closed 3 months ago

sadie-niblett commented 3 months ago

In the GetBinIndex() method we search _binLimits, which is made up of the lower limits of the bins (at some point it looks like the upper bound was being used too, but those sections have been commented out). For the most part, this method is working as intended, but it seems that it won't return the index of the last bin correctly. For a histogram with 10 bins, I've been passing the lower bound at each bin, and it returns correct until the last bin at index 9 where it returns 8. I've tried passing the midpoint of each bin instead, but I get the same results. For a histogram with 20 bins, passing the lower bound fails at index 17. Passing the midpoint of each bin fails at the last index, returning 18 instead of 19. Is there something else I should try passing to the method?

HadenSmith commented 3 months ago

Fixed this bug and cleaned up code and test.