function value = i4_uniform_sample ( a, b )

%*****************************************************************************80
%
%% I4_UNIFORM_SAMPLE returns a scaled pseudorandom I4 between A and B.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license. 
%
%  Modified:
%
%    25 January 2018
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer A, B, the limits of the interval.
%
%    Output, integer VALUE, a number between A and B.
%

%
%  We prefer A < B.
%
  a2 = min ( a, b );
  b2 = max ( a, b );

  u = r8_uniform_01_sample ( );
%
%  Scale to [A2-0.5,B2+0.5].
%
  u = ( 1.0 - u ) * ( a2 - 0.5 ) ...
    +         u   * ( b2 + 0.5 );
%
%  Round.
%
  value = round ( u );
%
%  Enforce limits.
%
  value = max ( value, a2 );
  value = min ( value, b2 );

  return
end
