1

I am working on an algorithm to compute multiple mean max values of an array. The array contains time/value pairs such as HR data recorded on a Garmin device over a 5 hour run. the data is approx once a second for an unknown period, but has no guaranteed frequency. An example would be a 10 minute mean maximum, which is the maximum average 10 minute duration value. Assume "mean" is just average value for this discussion. The desired mean maximal value's duration is arbitrary, 1 min, 5 min, 60 min. And, I'm likely going to need many of them-- at least 30 but ideally any on demand if it wasn't a lengthy request.

Right now I have a straight forward algorithm to compute on value:

1) Start at beginning of array and "walk" forward until the subset is equal to or 1 element past the desired duration. Stop if end of array is reached.

2) Find the average of those subset values. Store as max avg if larger than current max.

3) Shift a single value off the left side of array.

4) Repeat from 1 until end of array met.

It basically computes every possible consecutive average and returns the max. It does this for each duration. And it computes a real avg computation continuously instead of sliding it somehow by removing the left point and adding the right, like one could do for a Simple-moving-average series. It takes about 3-10 secs per mean max value depending on the total array size.

I'm wondering how to optimize this. For instance, the series of all mean max values will be an exponential curve with the 1s value highest, and lowering until the entire average is met. Can this curve, and all values, be interpolated from a certain number of points? Or some other optimization to the above heavy computation but still maintain accuracy?

4

1 回答 1

1

“它会连续计算一个真正的平均计算,而不是通过移除左边的点并添加右边的方式来滑动它,就像一个简单移动平均系列可以做的那样。”

为什么不直接滑动它(即保持一个运行总和除以该总和中的元素数量)?

于 2012-11-02T23:47:05.360 回答