function cr_prob = cr_prob_update ( cr_dis, cr_num, cr_ups )

%*****************************************************************************80
%
%% CR_PROB_UPDATE updates the CR probabilities.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    24 January 2018
%
%  Author:
%
%    Original FORTRAN90 version by Guannan Zhang.
%    MATLAB version by John Burkardt.
%
%  Input parameters:
%
%    Input, real CR_DIS(CR_NUM), the CR distances.
%
%    Input, integer CR_NUM, the total number of CR values.
%    1 <= CR_NUM.
%
%    Input, integer CR_UPS(CR_NUM), the number of updates 
%    for each CR.
%
%  Output parameters:
%
%    Output, real CR_PROB(CR_NUM), the updated CR probabilities.
%
  for i = 1 : cr_num
    cr_prob(i) = cr_dis(i) / cr_ups(i);
  end

  cr_prob_sum = sum ( cr_prob(1:cr_num) );

  cr_prob(1:cr_num) = cr_prob(1:cr_num) / cr_prob_sum;

  return
end 

