Constructing a piecewise function with a constant area under the curve for all pieces

24 Views Asked by At

There is a list of times corresponding to flashes of the status indicator LED of an electric power meter. The LED flashes when 1 Wh of energy (E) has been used. Because energy is the product of power (P) and time, P(t) can be constructed piecewise from constant functions.

For example for a list of times 0, 2, 3, 3.5, 4 (hours):

  • $For 0 <= t < 2: P(t) = 0.5$
  • $For 2 <= t < 3: P(t) = 1$
  • $For 3 <= t < 3.5: P(t) = 2$
  • $For 3.5 <= t < 4: P(t) = 2$

However, power consumption is continuous. The constraint of having an area of 1 Wh (the unit of power is watt) for each piece and fixing P(0) at 0 determines these linear functions:

  • $For 0 <= t < 2: P(t) = 0 + 0.5t$
  • $For 2 <= t < 3: P(t) = 1 + 0t$
  • $For 3 <= t < 3.5: P(t) = -11 + 4t$
  • $For 3.5 <= t < 4: P(t) = 17 + -4t$

Continuing the list with 0.5 h increments would result in P(t) bouncing between 1 and 3, which is counterintuitive. (Constant of 2 would be intuitive.)

Nearest-neighbor constant interpolation could be used by relaxing the requirement of having the area corresponding to each interval (two consecutive time points) be 1 Wh and having the function pieces have the constant area. The first and last segment could have an area of 0.5 Wh. Times 0, 2, 3, 3.5, 4, 4.5, 5

  • $For 0 <= t < 1: P(t) = 0.5$
  • $For 1 <= t < 2.5: P(t) = 2/3$
  • $For 2.5 <= t < 3.25: P(t) = 4/3$
  • $For 3.25 <= t < 3.75: P(t) = 2$
  • $For 3.75 <= t < 4.25: P(t) = 2$
  • $For 4.25 <= t < 4.75: P(t) = 2$
  • $For 4.75 <= t < 5: P(t) = 2$

This isn't horrible, because the ratio of the area under the curve between two time points $[t_n, t_{n+k}[$ and the energy indicated by the number of time points between those two points would converge to 1 the larger the interval is. Linearly interpolating between the time points would preserve this property and give a continuous function that doesn't counterintuitively fluctuate.

How would I go about constructing a function that's continuous, its area is a constant between any two consecutive time points and is intuitive in the ways I tried my best to illustrate? Can the constant values of the last method be set so that the second property is true?

I'd like to add plots of the functions mentioned, but I don't know how best to do that. Tips or edits welcome.