function y = golomb_average_wordsize(h,x,m)
    y = 0;
    
    k = ceil(log(m)/log(2));
    c = 2^k - m;
    
    for i = 1 : size(x,2)
        y = y + (floor(double(x(i))/m) + 1)*h(i);
        r = x(i) - m*floor(double(x(i))/m);
        
        if (r < c)
            y = y + (k-1)*h(i);
        else
            y = y + k*h(i);
        end
    end
    
end

