I have two dimensional data stored in a sorted list of tuples, as follows:
data = [(0.1,100), (0.13,300), (0.2,10)...
The first value in each tuple, the X value, occurs only once for a list of tuples. In other words, there can only be one value for 0.1, etc.
Then I have a sorted list of buckets. A bucket is defined as a tuple containing a range and identifier, as follows:
buckets = [((0,0.14), 2), ((0.135,0.19), 1), ((0.19,0.21), 2), ((0.19,0.24), 3)...
The range refers to the X axis. Thus, id 2 has two buckets above, and identifiers 1 and 3 have only one, respectively. The first bucket for id 2 has a range from 0 to 0.14. Please note that buckets may overlap.
So, I need an algorithm that transfers data to buckets, and then adds estimates. For the data above, the result will be:
1:0 2:410 3:10
Note that each piece of data is captured by the bucket associated with ID 2, so it gets a score of 100+300+10=410 .
How can I write an algorithm for this?