简体   繁体   中英

Moving data using weighted average

I have one table

range, value
0-15, 23
15-25, 34
25-35, 99
35-45, 100
45-50, 109

now what I want to is move this table

range, value
0-25, [23*(15/25) + 34*(10/25)]
25-50, ....

So I want to take the weighted average for example ..

0-25 => [0-15, 15-25]
     => [0.6, 0.4] % contribution
     => [0.6*23 + 0.4*34]

but It has to be so that given any [0-3,3-17,17-88] range to range that I can define [0-10, 10-25...].

I really have no idea where to start. It would be great if you can just give me a bit of help to get going.

My advice is to treat the original table as a step function (ie, a function which is constant almost everywhere and jumps from one value to another). Then construct the second table by computing integrals (areas under the curve) of the step function. You can think first about a continuous function -- you would construct the second table by computing integrals between each two end points, right? Same idea applies to the step function, except that you have to take the jumps at the original end points into account.

This idea essentially assumes that the data from which the first table was constructed as spread uniformly. That may or may not be true, but in the absence of further information (eg, the original data themselves) you can't do better.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM