I have a time series of recoreded frequencies, from which I would like to calculate secondly means. However the sample rate is not constant, which means that a simple arithmetic mean is wrong. What I would actually like to compute is the integral of the step function (described by the timeseries) within each secondly interval.
Consider for example this time series:
08:11:23.400 -> 49.9 Hz
08:11:24.200 -> 50.1 Hz
08:11:24.600 -> 50.15 Hz
08:11:24.800 -> 50.05 Hz
08:11:25.100 -> 49.95 Hz
The arithmetic mean of the second 08:11:24.000 - 08:11:25.000
would be (50.1 + 50.15 + 50.05)/3 = 50.1. But this is not the mean fequency measured in that second. It is instead:
(200*49.9 + 400*50.1 + 200*50.15 + 200*50.05)/1000 = 50.06, because the measured frequencies were true for different amounts of time.
This is the calculation of a weighted mean (with the hold times as weights) or equivalently the calculation of the integral of the step function (and then deviding by the time).
First of all: Is there a name for this specific calculation? It seems a rather standard computation on time series to me. Not knowing a name for this makes it hard to google for it.
Second: Which java library supports such a calculation? I would like to avoid implementing this by myself. I refuse to believe that there is no good standard java library offering this. I was looking into the apache commons math library but without any luck (but again: maybe I'm just missing the correct term to look for).