Using Macro: Find optimal bin size for data pasted by user to create a histogram

WaqasTariq

Board Regular
Joined
Jun 26, 2012
Messages
58
Office Version
  1. 365
I am trying to find a way to create optimal bin size for the data (random size/rows - based on user input) provided by user to create a histogram. The data has random times within a 24 hour time period along with varying quantities.

I did find two methods online, but they had issues;

  1. The first method was to take a count of the data points, then take a square root (rounded) and then divide the specification tolerance by number of bins using the table article had.
  2. The second used Kernel Density Estimation (KDE), which is what I want to use, but wanted me to buy their plugin.

How can I use Kernel Density Estimation (KDE) to find optimal bin size for my data? The data will be of varying amount (rows) each time.

Here is how the data looks like, example excel file attached as well.

Time Quantity
0:30 1
1:15 2
1:30 4
1:45 5
2:05 6
2:25 7
2:45 6
3:15 4
0:30 1
1:15 2
1:30 4
1:45 5
2:05 6
2:25 7
2:45 6
3:15 4
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top