Generate array of bin sizes in Excel

戏子无情 提交于 2019-12-24 02:01:59

问题


The FREQUENCY function in Microsoft Excel is useful for generating histograms. The first parameter is an array of data values (E.g. A1:A100). The second one is an array of bin sizes. I want to generate this array from three parameters:

  • Minimum data value: MIN(A1:A100)
  • Maximum data value: MAX(A1:A100)
  • Bin size: constant

That is, a formula/function should return the list of wanted values instead of manually putting them in cells.

E.g. Consider a minimum value of 10, a maximum value of 100 and a bin size of 20. This would yield an array of the follow bin sizes: 10, 30, 50, 70, 90

How can I accomplish this? Thanks.


回答1:


If you want that array generated by a formula try this

=(ROW(INDIRECT("1:"&CEILING((MAX(A1:A100)-MIN(A1:A100))/B1,1)))-1)*B1+MIN(A1:A100)

where B1 is your bin size constant, e.g. within the FREQUENCY function that would be

=FREQUENCY(A1:A100,(ROW(INDIRECT("1:"&CEILING((MAX(A1:A100)-MIN(A1:A100))/B1,1)))-1)*B1+MIN(A1:A100))

confirmed with CTRL+SHIFT+ENTER



来源:https://stackoverflow.com/questions/9570168/generate-array-of-bin-sizes-in-excel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!