proj home

Files   Classes   Functions   Hierarchy  

histogramtest.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 using namespace std;
00003 
00004 #include <commandline.h>
00005 #include <histogram.h>
00006 #include <histogramtest.h>
00007 #include <print.h>
00008 #include <random.h>
00009 
00010 
00011 void histogramtest::test01(int argc, char**argv)
00012 {
00013   commandline c(argc,argv);
00014 
00015   uint N = 5;
00016   double wmax=10.0;
00017 
00018   c.mapvar(N,"N");
00019   c.mapvar(wmax,"wmax");
00020 
00021   random11<double> r;
00022 
00023   histogram<double> hg(0.0,wmax,N);
00024 
00025   uint samples = 200;
00026   c.mapvar(samples,"samples");
00027   //c.enablehelp(cout);
00028   c.enablehelp();
00029 
00030   cout << SHOW(N) << "   -the number of intervals." << endl;
00031   cout << SHOW(wmax) << "   -the random variable is [0,wmax]" << endl;
00032   cout << SHOW(samples) << endl;
00033   cout << endl;
00034 
00035   for (uint i=0; i<samples; ++i)
00036     hg.eval(wmax*r());
00037 
00038   cout << hg << endl;
00039 
00040   vector<double> fd;
00041   hg.frequencydist(fd);
00042 
00043   for (uint i=0; i<fd.size(); ++i)
00044     cout << fd[i] << " ";
00045   cout << endl << endl;
00046 
00047   hg.printfrequencydistpair(cout);
00048 }
00049 
00050 

Generated on Fri Mar 4 00:49:28 2011 for Chelton Evans Source by  doxygen 1.5.8