Excel Histogram How does it calculate bin width

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 13K views
Saladsamurai
Messages
3,009
Reaction score
7
Hey people,


I am trying to write my own histogram making code since the Excel one sucks IMO. I am having some trouble thinking the whole bin 'width' thing through though.
I plan on using the formula

number of bins = k = 1.87(N - 1)0.40 + 1​

Then I was going to figure out the bin width as

[tex]\frac{[MAX(data ) - MIN(data )]}{k}[/tex]​

This will get me in the ball park, but it will result in bin widths that are sloppy like 1.111 - 2.222 and the like. They should be sensible intervals like: 0 - 10, 10 - 20... etc or 0.10 - 0.12, 0.12 - 0.14...etc
Anyone care to brainstorm on me with this? I was thinking I could do some sort of test on the data set to determine what decimal place the bin width needs to go out to.

Hopefully someone can decipher what I am talking about here and wants to jump on board! :smile:
 
Last edited:
Physics news on Phys.org