问题
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