I need to calculate the cumulative decreasing sum as a field in a rasters attribute table. The cumulative decreasing sum is the accumulation of the last values to the first, so it is basically the ordinary cumulative (or cumulative increasing) sum in reverse order. I recently asked a similar question; how to calculate the ordinary cumulative sum, which was answered by pasting the following in the pre-logic script box of the field calculator,
total = 0 def cumsum(inc): global total total+=inc return total
before running the "cumsum" operation on the source field.
This works well. I would prefer if someone could adapt this script to calculate the cumulative decreasing sum instead, but I'm open to any suggestions.
Please note that I have very limited scripting tools, so if the solution you provide is not simply an adaptation of the above script, please detail your solution in a step by step manner.