Excel Histogram How does it calculate bin width

Click For Summary
The discussion centers on creating a custom histogram code to improve upon Excel's functionality, specifically addressing challenges with bin width calculations. The proposed formula for determining the number of bins is k = 1.87(N - 1)0.40 + 1. The user seeks to calculate bin width using the formula (MAX(data) - MIN(data)) / k, but expresses concern that the resulting bin widths are often inexact, such as 1.111 to 2.222, rather than more practical intervals like 0-10 or 0.10-0.12. Suggestions are sought for refining the bin width to ensure sensible intervals, including the idea of testing the dataset to identify the appropriate decimal precision for bin widths. The user invites collaboration to brainstorm effective solutions.
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

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

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
Any thoughts :smile:
 

Similar threads

Replies
7
Views
5K
  • · Replies 8 ·
Replies
8
Views
7K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
15K
Replies
1
Views
3K
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 4 ·
Replies
4
Views
6K