我在一个文件中有 x 值和相应的计数。我将其读为以下形式的元组列表
dat = [(0.02, 1),
(0.0211, 1),
(0.021, 1),
(0.023, 1),
(0.0251, 1),
(0.12, 2),
(0.141, 1),
(0.14, 3),
(0.171, 1),
(0.462, 9),
(0.467, 10),
(0.478, 15),
(0.804, 20),
(0.815, 31),
(0.815, 24),
(2.72, 164),
(2.78, 147),
(2.8, 128),
(5.78, 6),
(5.83, 1),
(5.8603, 1),
(5.94, 17),
(8.63, 3),
(8.87, 5),
(18.601, 1),
(19.0, 7),
(21.0, 2),
(22.0, 4)]
如何将这些转换为相等的间隔计数。例如,增量为 0.2 的间隔。
x count
0 0
0.5 12
1.0 75
1.5 0
2.0 0
2.5 0
3.0 439
...