
/*   random_demo_2_series.c                                         */
/*   Demonstration of random numbers                                */
/*   Pseudo random numbers generated by RAND() from gcc             */
/*   Demo illustrating the dependence of different sequences        */ 
/*                                                                            */
/*   Syntax:                                                                  */

/*   random_demo_2_series 2 4000 | plot_data -p -l 0 1 0 1 -x x -y y -h "2 series"     */

/*   random_demo_2_series 1 4000 | plot_data -p -l 0 1 0 1 -x x -y y -h "1 series"     */


#include <stdlib.h>

int main( int argc, char *argv[] )
{
  int icase, i, N;
  double x, y;

      if ( argc != 3 )
	{
          printf( "\n" );
          printf( "Syntax: random_demo  case N \n" );
          printf( "Case: 1 - one sequence \n" );
          printf( "      2 - 2 sequences \n\n" );
          exit(1);
	}
      icase = atoi( argv[1] );
      N = atoi( argv[2] );

      if ( icase == 1 )
	{
          srand(1);
          for ( i=0 ; i<N ; i++ )
	    {
              x = (double)rand()/(double)RAND_MAX;
              y = (double)rand()/(double)RAND_MAX;
              printf( " %f %f\n", x, y );
	    }
	}
      else if ( icase == 2 ) 
	{
          srand(1);
          for ( i=0 ; i<N/2 ; i++ )
	    {
              x = (double)rand()/(double)RAND_MAX;
              y = (double)rand()/(double)RAND_MAX;
              printf( " %f %f\n", x, y );
	    }
          srand(2);          
          for ( i=N/2 ; i<N ; i++ )
	    {
              x = (double)rand()/(double)RAND_MAX;
              y = (double)rand()/(double)RAND_MAX;
              printf( " %f %f\n", x, y );
	    }
	}
      else
        {
           printf( " Case can only be 1 or 2 \n\n" );
           exit(1);
	}


}

