# Calculating gradient/rate of use

I have some data regarding my pellet usage.

I monitor the level of pellets in the hopper, with a certain degree of inaccuracy because of the tesselation of the pellets.

I would like to calculate the gradient of each usage cycle. From the graph below I deduce that my rate of use for he first and third cycle are about the same, but the rate for the second cycle is lower. I would like to be able to calculate the actual rate (gradient), eventually from the raw data, but that leaves me with two things to figure out;

1. Calculating when the hopper is filled (the peaks)(simple, that's when the difference between n and n+1 and n+2 is positive instead of negative)
2. Calculating the gradient from the last peak to the last valley, or the latest measurement.