/*@@@@@@@@@@@@@@@@@@@@@@@@ testgen.cpp @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 Random Option Pricing
 Summer 2002
 Authors: A. Korobchevsky
          S. Ferrando
 Ryerson University ALL RIGHTS RESERVED
 
 Purpose: Tests the random generator from GNU Scientific Library.
          The user picks generator name, fraction and number of hits.
	  Generators supported so far: 
                 MT19937 (use mt as an argument)
		 Tausworthe (taus)
		 GFSR4     (gfsr)
	  See GSL Online Documentation for more information.
	  Fraction must in 0..1
	  Number of hits is recommended to be large ( >> 1000 )

	  The program will use the specified generator to get a specified 
	  number of uniforms by the hits parameter. Each uniform is compared 
	  with a fraction. The number of uniforms below the fraction is 
	  summed up.
	  Example:
	     ./testgen mt 0.3 100000
	     Generator MT19937 will be picked
	     100000 [0..1] uniforms will be generated
	     Each will be compared to 0.3, if below the counter will be
	      incremented
	     Result (on my machine) is 29988 uniforms are below 0.3 which is
	     satisfactory.
	  Can be used with standard UNIX time utility.
	  Alternative tests: Pi, Diehard
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include <iostream>
#include <cstdlib>
using namespace std;

#include "../GSL_RandomGen.h"



// BEGIN All
int main(int argc, char** argv)
{ if (argc != 4)
  { cout << "Usage: ./testgen generator fraction hits " << endl;
    exit(1);
  }
 
  GSL_RandomGen gen(argv[1]);
  double frac = atof(argv[2]);
  long sim = atol(argv[3]);

  int count = 0;
  for (int i = 0; i < sim; i++)
  { double eps = gen.next();
    if (eps < frac)
      count++;	
  }
  cout << "Simulations: " << sim << endl;
  cout << "Generator: " << argv[1] << endl;
  cout << "Fraction: " << frac << endl;
  cout << "Hits: " << count << endl;
}

// END All
