function [out,devlist] =findperiod(data)

mindev = std(data);
devlist = [];
for i=2:floor(length(data)/2)
    [prdata,avglist] = seasrem(data,i);
    dev = std(prdata);
    if dev< mindev
        out = i;
        mindev = dev;
    end;
    devlist = [devlist dev];
end;
x=2:floor(length(data)/2);
figure;
plot(x,devlist); grid on;
legend('\sigma_x');
xlabel('periodicity removed');
ylabel('deviation');
title('Standard Deviation of a series with a periodicity removed');
disp(num2str(out))
