I have a long list of events consisting of pairs
{{e_1,w_1},{e_2,w_2}, ....{e_n,w_n}}
I want to bin the energies e_i and then sum the 'weights' w_i of all events in a particular bin of energy e. The w_i are not true weights, because some of them can be negative. Thus I cannot use WeightedData. What is an efficient way to achieve this binning with 'weight' summation in each bin?
Here is some example data:
em = {1, 1.5, 3., 4., 2.1, 7.3, 6., 8.5, 9.9, 5.7}
w = {10, 5, 3, 2, 5, 10, 20, 5, -7, 8}
The bins are 0-5 and 5-10, and the result should be {25, 36}.
GroupBy
based on aRound
ede
value? $\endgroup$ – Szabolcs Jun 22 '18 at 19:06Total[Map[#[[1]]#[[2]]&, {{e_1,w_1},{e_2,w_2}, ....{e_n,w_n}}]
? $\endgroup$ – Ulrich Neumann Jun 22 '18 at 19:23