excel - 评估频率公式的中间步骤
问题描述
这参考了 [SO question]根据其他范围的标准计算范围中的唯一项目列表 Scot Craner 建议的公式是:
=SUM(--(FREQUENCY(IF(B2:B7<=25,IF(C2:C7<=35,COUNTIF(A2:A7,"<"&A2:A7),""),""),COUNTIF(A2:A7,"<"&A2:A7))>0))
除了所附快照中显示的这一步外,我已经能够清楚地理解公式的逻辑和评估。根据 MS Office 文件:
FREQUENCY(data_array, bins_array) FREQUENCY 函数语法具有以下参数: Data_array 必需。要计算频率的一组值的数组或引用。如果 data_array 不包含任何值,则 FREQUENCY 返回一个零数组。Bins_array 必需。要将 data_array 中的值分组到其中的区间数组或引用。如果 bins_array 不包含任何值,则 FREQUENCY 返回 data_array 中的元素数。
我很清楚 {1;1;4;0;"";"") 如何进入 data_array 以及 {1;1;4;0;5;3} 如何进入 bins_array。但它如何评估到 {2;0;1;1;0;0;0} 我不清楚。如果有人能清楚地解释它,将不胜感激。
解决方案
所以你想知道如何
FREQUENCY({1;1;4;0;"";""},{1;1;4;0;5;3})
评估为{2;0;1;1;0;0;0}
?
问题是bins_array
不需要排序才能FREQUENCY
正常工作。但当然,它必须在内部对 进行排序bins_array
以获取将 中的值分组到的区间data_array
。然后它分组和计数,然后以与 bin 中给出的相同顺序返回计数的数字 bins_array
。
Scores Bins
1 1
1 1
4 4
0 0
"" 5
"" 3
Bins sorted
0 (<=0)
1 (>0, <=1)
1 (>1, <=1) == not possible
3 (>1, <=3)
4 (>3, <=4)
5 (>4, <=5)
(>5)
Bin Description Result
1 Number of scores (>0, <=1) 2
1 Number of scores (>1, <=1) == not possible 0
4 Number of scores (>3, <=4) 1
0 Number of scores (<=0) 1
5 Number of scores (>4, <=5) 0
3 Number of scores (>1, <=3) 0
Number of scores (>5) 0
推荐阅读
- javascript - 在 React/JavaScript 中为二维数组赋值
- ecmascript-6 - 未捕获的类型错误:代理上的“ownKeys”:陷阱结果不包括“长度”
- python - 将 `runpy` 与 mock 组合在单独运行时通过,但在与其他测试一起运行时失败
- python - 为什么我不能在 pyqt5 gui 中嵌入的 matplotlib 颜色图中成功绘制感兴趣区域?
- java - Springboot - 在@Async方法中调用@Transactional方法,事务不起作用
- db2 - 日志接收器中没有删除条目?
- python - 如何为 Django 应用程序定义基本 style.css 文件
- python - 如何在循环中的每个变量中添加一个值?
- pandas - 在 Pandas UDF 中,是否可以返回包含嵌套列表的系列?
- mysql - 在 SQL 中将 ID 交换为字符串