question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Histogram countsFracCurve should not be normalized by default

See original GitHub issue

I’m no statistics guy but is this correct behaviour?

I would have expected the distribution curve to be scaled accordingly to the histogram, but it seems to only work if the histogram range of values is 100 exactly.

var plt = new ScottPlot.Plot(600, 400);

Random rand = new Random(0);
double[] values = DataGen.RandomNormal(rand, pointCount: 10000, mean: 50, stdDev: 5);
hist = new ScottPlot.Statistics.Histogram(values);

double barWidth = hist.binSize * 1.2; // slightly over-side to reduce anti-alias rendering artifacts

plt.PlotBar(hist.bins, hist.countsFrac, barWidth: barWidth, outlineWidth: 0);
plt.PlotScatter(hist.bins, hist.countsFracCurve, markerSize: 0, lineWidth: 2, color: Color.Black);
plt.Title("Normal Random Data");
plt.YLabel("Frequency (fraction)");
plt.XLabel("Value (units)");
plt.Axis(null, null, 0, null);
plt.Grid(lineStyle: LineStyle.Dot);

plt.SaveFig("Advanced_Statistics_Histogram.png");

Advanced_Statistics_Histogram

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
LB767commented, Nov 22, 2020

Awesome! Looking very much forward to the next major release (multiple Y axes 😄)

0reactions
swhardencommented, Nov 23, 2020

Just fixed this in 4.0.44 (on NuGet now) and it works as expected

var hist = new ScottPlot.Statistics.Histogram(values);
plt.PlotBar(hist.bins, hist.countsFrac, barWidth: hist.binSize * 1.2, outlineWidth: 0);
plt.PlotScatter(hist.bins, hist.countsFracCurve, markerSize: 0, lineWidth: 2, color: Color.Black);

image

Thanks again for noting this issue! Scott

Read more comments on GitHub >

github_iconTop Results From Across the Web

Should histograms be normalized first before fitting them?
Generally speaking, you shouldn't be using histograms to estimate parameters (unless you really have to; see bottom part of this answer for ...
Read more >
Why does the normalized histogram give wrong y values ...
When the density keyword argument is set to True , the output histogram is normalized by the sum of each bin count so...
Read more >
Problem in Histogram Normalization
Dear experts,. I"m tring to normalize some histograms both to its bin width and its number of events with the following function.
Read more >
Histograms
It is often desirable to normalize the histogram in some way. To do this, the normalize attribute is used, and we want normalize=:pdf...
Read more >
matplotlib.axes.Axes.hist2d — Matplotlib 3.1.0 documentation
All values outside of this range will be considered outliers and not tallied in the histogram. ... Normalize histogram. normed is a deprecated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found