function d = reduceSpikes(data)
% data is a vector of numbers
% Replace every point with the mean of its 5-point neighborhood

n= 5;           % neighborhood length
h= floor(n/5);  % half neighborhood length

d= data;

% Interior values
for k= h+1:length(data)-h
    d(k)= mean(data(k-h:k+h));
end

% Values at the ends of the vector
for k=1:h
    left= max(1, k-h);
    d(k)= mean(data(left:k+h));
end
for k= length(data):-1:length(data)-h+1
    right= min(length(data),k+h);
    d(k)= mean(data(k-h:right));
end


