Skip to content

Histogram function ignores requested bucket size #2299

@Xerxes004

Description

@Xerxes004

Bug Report

Issue: Histogram bucket size is ignored when producing bin edges.

Common.Histogram has an overload that looks like:

(double[] hist, double[] binEdges) Histogram(double[] values, double min, double max, double binSize, bool density = false);

The binEdges returned by this function don't have a spacing of binSize as expected.

For example, if I specify binSize of 1.5, and my data goes from 1 to 3, I would expect the edges to be [1.5, 3.0]. Instead, they are [1.0, 2.0]. These buckets work just fine and the histogram is valid, but the bucket sizes are not the size I requested.

Reproducing: Run the following code and print out the results:

double[] data = new double[] {1.0, 2.0, 3.0};
var (_, leftEdges) = ScottPlot.Statistics.Common.Histogram(data, 1.0, 3.0, binSize: 1.5);

System Details

  • ScottPlot Version: 4.1.59
  • Operating System: Windows 10
  • Application Type: WPF
  • .NET Version: .NET 7.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions