-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Labels
BUGunexpected behaviorunexpected behavior
Description
Bug Report
Issue:
Creating a histogram with any value that is equal to the max value will throw 'System.IndexOutOfRangeException', if there are more values than bins. This happens easily when using the overload that takes the binSize and not the bin count.
This is the offending code, taken from ScottPlot.Statistics.Common.Histogram
double[] hist = new double[binCount];
...
if (values[i] == max)
{
hist[values.Length - 1] += 1;
continue;
}Even with only a few values this can get out of bounds easily, as long as the min and max properties reduce the binCount to less than the value count.
Reproducing:
Use the following code to easily reproduce the exception.
var values = new double[] { 10, 20, 20, 10, 20, 10, 20, 10, 10, 20, 10, 10, 20, 15, 10, 30 };
var (counts, binEdges) = ScottPlot.Statistics.Common.Histogram(values, 15, 30, 1, false);System Details
- ScottPlot Version: 4.1.25
- Operating System: Windows 10 Pro 21H1
- Application Type: console
- .NET Version: .NET core 3.1 LTS
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BUGunexpected behaviorunexpected behavior