function a_out = bucket(data,window)

isodd = mod( window, 2 );

if (isodd)
    window = window + 1;
end

lower  = floor( window/2 );
higher = ceil( window/2 );

min = 0;
max = 0;

dataLength = length(data);
a_out(dataLength) = 0;

for i=1:dataLength
    
    min = i-lower;
    max = i+higher;
    if (min<1)
        min = 1;
    end
    if (max>dataLength)
        max = dataLength;
    end
    a_out(i) = sum( data(min:max) );
end