function data = sinus ( m )

%*****************************************************************************80
%
%% SINUS samples a noisy sine function.
%
%  Discussion:
%
%    For any given value of M, the same set of X and S will always be returned.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    20 February 2019
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer M, the number of values desired.
%
%    Output, real DATA(M,2), abscissas and values for the noisy sine function.
%

%
%  R1 and R2 are the magnitudes of the two noise components.
%
  r1 = 0.1;
  r2 = 0.1;
%
%  Initialize the random number generator so that it always returns the same
%  set of values for a given value of M.
%
  seed = m + 123456789;
  rng ( seed )
%
%  Choose M values X in [0,2pi].
%
  x = 2.0 * pi * rand ( m, 1 );
%
%  Evaluate S = sin(x) + scaled normal noise + uniform noise.
%
  s = sin ( x ) ...
    + r1 * randn ( m, 1 ) .* abs ( sin ( x ) ) ...
    + r2 * ( 2.0 * rand ( m, 1 ) - 1.0 );
%
%  For convenience in plotting, sort by X value.
%
  [ x, in ] = sort ( x );
  s = s(in);

  data = [ x, s ];

  return
end
