What would cause a histogram to have regular spikes in bin counts?

7 Comments
Answers (2)
Your code and your file don't quite match up with each other (e.g. variable named "displacement" rather than "N") and also you have not defined some of the variable you used (e.g. binsize).
Nonetheless, I was able to replicate something close to what you are seeing using your data file and this code:
load data
binsize = 0.001; maxbin = 0.5; binranges = 0:binsize:maxbin;
bincounts = histc(displacement,binranges);
figure plot(binranges,bincounts)

If I just let MATLAB make 100 bins, I get a relatively smooth curve (although you can see some hints of spiky behavior):

But if I increase the number of bins to 800, it gets very spiky like your original:

So, I would conclude that this is definitely a result of how you are enforcing the binning.
4 Comments
The data you uploaded are definitely clumped. Try this code, where I have "jittered" the data a little bit, and zoomed in.
figure plot(sort(displacement)+0.00005*randn(size(displacement)),rand(size(displacement)),'.') xlim([0.095 0.125]) ylim([-0.5 1.5])

You can see structure at spacing of about 0.001, and the density of points around 0.015. There is also a decreased density at around 0.018, but that is not as easy for the eye to perceive in this chart. The best way to perceive that is -- the histogram!
1 Comment
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
