Anomalous histogram for small argument
Show older comments
Running the following code from the command line with c = 1e-15 or greater leads to a normal histogram
c = 1e-15; figure; histogram(c * rand(100,1))

Running the following code with c = 1e-16 or less leads to an incorrect histogram
c = 1e-16; figure; histogram(c * rand(100,1))

The problem appears also in apps when the histogram function is invoked.
Is this a bug?
Gordon
Accepted Answer
More Answers (1)
Jackson Burns
on 7 Sep 2019
Here's a similar question asked a few years ago which was never really solved either. This comment may be your best approach, but I would reccomend just bringing the values to unity with something like this:
c = 1E-16;
figure
mydata = c * rand(100,1);
histogram(mydata./max(mydata))
You could then modify the xticklabels to match whatever the original values were.
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!