function r = prune_errs_C45(rN,re,coeff)
% PRUNE_ERRS_C45 computes the reduction in advantage if the error rate
%	increases to the upper limit of the confidence level.  The
%	coefficient is the square of the number of standard deviations
%	corresponding to the selected confidence level. (see M-file
%	prune_det_coeff.m for more details).
%
%	r = prune_errs_C45(rN,re,coeff)
%
%	rN: number of points in node
%	re: number of points expected to misclassified if given rN of them
%	coeff: coefficient determined by prune_det_coeff, based on given
%	       certainty factor.

% begin
global CF;

N = ceil(rN);
e = fix(re);
 
if (e + 0.5 >= N)
	r = 0.0;
	return;
end

if ( e ~= 0 )

	Pr = (e + 0.5 + coeff/2 + sqrt(coeff * ((e + 0.5) * (1 - (e + 0.5)/N) + coeff/4)) ) / (N + coeff);

else
	Pr = -exp((log(CF))/rN);
	Pr = Pr + 1.0;

end

r = rN*Pr - re;




