function avgdiff=error_prirasheniya(y,yprogn,nbeg,nend,dt);
% Функция вычисляет соответствие двух рядов по приращениям с определенным
% дт.
if (length(y)<nend)
    nend=length(y);
end
if (length(yprogn)<nend)
    nend=length(yprogn);
end

y_fragment=y(nbeg:dt:nend);
yprogn_fragment=yprogn(nbeg:dt:nend);
n_yf=length(y_fragment);
y_prirash=y_fragment(2:n_yf)-y_fragment(1:n_yf-1);
n_ypf=length(yprogn_fragment);
yprogn_prirash=yprogn_fragment(2:n_ypf)-yprogn_fragment(1:n_ypf-1);

diff=y_prirash-yprogn_prirash;
diffsigns=sign(y_prirash).*sign(yprogn_prirash);
distsigns=ones(size(diffsigns))-diffsigns;
if (size(diff,1)>size(diff,2))
    diff=transpose(diff);
end

%figure;
%plot(distsigns);
%hold on;
%plot(yprogn_prirash);
%figure;
%plot(diff);
%figure;
%plot(y_fragment);
%hold on;
%plot(yprogn_fragment);
%avgdiff=sum(abs(diff))/n_ypf;
avgdiff=sum(abs(distsigns))/n_ypf;



