
The procedure is pretty straight forward, replace each entry in the vector containing the histogram with mean of that entry along with n entries backwards n entries forward. Boundary case arises when the index of the current entry is bellow n or beyond length_of_vector-n, I chose to keep those entries unchanged.
    result = arr ;
    for i=n+1:length(arr)-n
        sum=0;
        for j=i-n:i+n
            sum = sum + arr(j) ;
        end
        result(i) = sum/(2*n+1);
    end
 
 
No comments:
Post a Comment