-
热度指数:774
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
-
算法知识视频讲解
编写一个Python函数来计算给定数据集的各种描述性统计指标。该函数应采用数值列表或NumPy数组,并返回包含平均值、中位数、众数、方差、标准差、百分位数(第25、50、75)和四分位数范围(IQR)的字典。
需要计算的统计指标包括:
1. 平均值(mean)
2. 中位数(median)
3. 众数(mode)
4. 方差(variance)
5. 标准差(standard_deviation)
6. 25th百分位数(25th_percentile)
7. 50th百分位数(50th_percentile)
8. 75th百分位数(75th_percentile)
9. 四分位距(interquartile_range)
输入描述:
输入为一行需要计算统计指标的数据集。
输出描述:
输出一个字典,包含以下键值对:
- "mean": 平均值
- "median": 中位数
- "mode": 众数
- "variance": 方差(保留4位小数)
- "standard_deviation": 标准差(保留4位小数)
- "25th_percentile": 第25百分位数
- "50th_percentile": 第50百分位数
- "75th_percentile": 第75百分位数
- "interquartile_range": 四分位距
示例1
输出
{'mean': 3.0, 'median': 3.0, 'mode': 1, 'variance': 2.0, 'standard_deviation': 1.4142, '25th_percentile': 2.0, '50th_percentile': 3.0, '75th_percentile': 4.0, 'interquartile_range': 2.0}
备注:
1. 对应的输入、输出已给出,您只用实现核心功能函数即可。
2. 支持numpy、scipy、pandas、scikit-learn库。