[Accumulators] Retract samples

Dear all, I am considering using Boost Accumulators for a moving window calculation. When a window would step from left to right, it should add the sample on the right side of the window and retract the sample on the left side on each step. For weighted accumulators, it might be possible to use negative weights. But, since the accumulators do not appear to be intended for this use, there may be implementation details that invalidate the use of negative weights. Is there a recommended way to retract samples in Boost Accumulators? Thanks, Alex p.s. the general idea: void movingwindowsum(const vector<double>& in, vector<double>& out, size_t radius ) { size_t n = in.size(); double sum = 0; // This should be an accumulator for(size_t i = 0; i < min(n, radius); ++i) { sum += in[i ]; // add sample } out.resize(n); for(size_t i = 0; i < n; ++i) { size_t left = i - radius - 1; size_t right = i + radius; if (left >= 0) sum -= in[left]; // retract sample if (right < n) sum += in[right]; // add sample out[i] = sum; }

On Dec 23, 2010, at 1:00 PM, Alex Hagen-Zanker wrote:
Dear all,
I am considering using Boost Accumulators for a moving window calculation. When a window would step from left to right, it should add the sample on the right side of the window and retract the sample on the left side on each step.
For weighted accumulators, it might be possible to use negative weights. But, since the accumulators do not appear to be intended for this use, there may be implementation details that invalidate the use of negative weights.
Is there a recommended way to retract samples in Boost Accumulators?
Thanks, Alex
Hi Alex, This is not the intended use of the accumulator library. Matthias

On 23/12/2010 15:40, Matthias Troyer wrote:
On Dec 23, 2010, at 1:00 PM, Alex Hagen-Zanker wrote:
Dear all,
I am considering using Boost Accumulators for a moving window calculation. When a window would step from left to right, it should add the sample on the right side of the window and retract the sample on the left side on each step.
For weighted accumulators, it might be possible to use negative weights. But, since the accumulators do not appear to be intended for this use, there may be implementation details that invalidate the use of negative weights.
Is there a recommended way to retract samples in Boost Accumulators?
Thanks, Alex Hi Alex,
This is not the intended use of the accumulator library.
Matthias
I was afraid so. It is a pity because I require so much of the functionality that is already in Boost Accumulators. Thanks, Alex

On 24 Dec 2010, at 09:59, Alex Hagen-Zanker wrote:
On 23/12/2010 15:40, Matthias Troyer wrote:
On Dec 23, 2010, at 1:00 PM, Alex Hagen-Zanker wrote:
Dear all,
I am considering using Boost Accumulators for a moving window calculation. When a window would step from left to right, it should add the sample on the right side of the window and retract the sample on the left side on each step.
For weighted accumulators, it might be possible to use negative weights. But, since the accumulators do not appear to be intended for this use, there may be implementation details that invalidate the use of negative weights.
Is there a recommended way to retract samples in Boost Accumulators?
Thanks, Alex Hi Alex,
This is not the intended use of the accumulator library.
Matthias
I was afraid so. It is a pity because I require so much of the functionality that is already in Boost Accumulators. Thanks, Alex
Maybe you can reuse the framework and the accumulators, and derive new stats classes and a framework that has a retract feature as well? Or you could look at the time series library. Matthias

On Jan 1 2011, Matthias Troyer wrote:
On 24 Dec 2010, at 09:59, Alex Hagen-Zanker wrote:
On 23/12/2010 15:40, Matthias Troyer wrote:
On Dec 23, 2010, at 1:00 PM, Alex Hagen-Zanker wrote:
Dear all,
I am considering using Boost Accumulators for a moving window calculation. When a window would step from left to right, it should add the sample on the right side of the window and retract the sample on the left side on each step.
For weighted accumulators, it might be possible to use negative weights. But, since the accumulators do not appear to be intended for this use, there may be implementation details that invalidate the use of negative weights.
Is there a recommended way to retract samples in Boost Accumulators?
Thanks, Alex Hi Alex,
This is not the intended use of the accumulator library.
Matthias
I was afraid so. It is a pity because I require so much of the functionality that is already in Boost Accumulators. Thanks, Alex
Maybe you can reuse the framework and the accumulators, and derive new stats classes and a framework that has a retract feature as well? Or you could look at the time series library.
Matthias
Yes, I think I'll reuse the framework, even though it is much more advanced than my usual standard. Another feature I will need to add is to accumulate subtotals. Do you know of any issues with that? I'd like to allow the following: acc a, b, c; // three identical accumulators a(1); // 1 a(2); // 1 + 2 b(3); // 3 b(4); // 3 + 4 c(a); // 1 + 2 c(b); // 1 + 2 + 3 + 4 c(5); // 1 + 2 + 3 + 4 + 5

On Jan 3, 2011, at 11:12 PM, Alex Hagen-Zanker wrote:
Yes, I think I'll reuse the framework, even though it is much more advanced than my usual standard.
Another feature I will need to add is to accumulate subtotals. Do you know of any issues with that? I'd like to allow the following:
acc a, b, c; // three identical accumulators a(1); // 1 a(2); // 1 + 2
b(3); // 3 b(4); // 3 + 4
c(a); // 1 + 2 c(b); // 1 + 2 + 3 + 4 c(5); // 1 + 2 + 3 + 4 + 5
No, this feature of "merging" accumulators has not been implemented but often requested. Matthias
participants (2)
-
Alex Hagen-Zanker
-
Matthias Troyer