Phil Steitz wrote:
> Mark R. Diggory wrote:
>
>>
>>
>> Phil Steitz wrote:
>>
>>>
>>> A useful extension to Univariate would be to support a "rolling"
>>> capability, as follows:
>>>
>>> Add a property called something like "windowSize" and change the
>>> contract to mean that getMean(), getVariance, etc. always return
>>> statistics on values {n, n1, ... nwindowSize+1}. Have the default
>>> windowSize "infinity" (i.e., no restriction). This would be useful
>>> in applications (e.g simulation monitors) that need to compute
>>> "rolling averages".
>>>
>>> Obviously, we would want to do this without storing all of the values
>>> {n, n1, ... nwindowSize+1}.
>>>
>>> Phil
>>>
>> Is there a strategy to do this without storing all the values of the
>> current window? if your just storing sum and sumsq, I'm not sure how
>> you would "back out" of the computation at the end of the window. Of
>> course, I may be missing something.
>>
>
> I have not actually implemented this, so of course *I* may be missing
> something, but is seems to me that you could just hold on to value
> number nwindowSize+1 and adjust the sums as new values get added. You
> would also have to hold onto some additional values for min, max to
> handle the case where the value being "rolled off" is the current min or
> max.
>
> Phil
>
This is where I draw a blank, to hold on to value number nwindowSize+1,
it would seem you need to retain {n, n1, ... nwindowSize+1} this is
because in the next roll {n > n1 , n1 > n2, ... nwindowSize >
nwindowsize+1}. this means that an array of values {n to
nwindowsize+1} would need to be retained so you would be able to do the
following calculations
sum = sum  values[windowsize];
sumsq = sumsq  Math.pow(values[windowsize], 2);
Then the array would get rolled where
for(int i = windowsize; i > 0 ;i){
values[i] = values[i1]
}
and the new value added to it:
values[0] = n;
sum = sum + values[0];
sumsq = sumsq + Math.pow(values[0], 2);
So, from what I can see, if the window isn't infinite, some storage
needs to occur. (But again, I could easily be missing something really
obvious here).
Mark

To unsubscribe, email: commonsdevunsubscribe@jakarta.apache.org
For additional commands, email: commonsdevhelp@jakarta.apache.org
