source: trunk/test/test_rnd.cc @ 13

Last change on this file since 13 was 13, checked in by daniel, 20 years ago

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 697 bytes
Line 
1#include <iostream>
2#include "random_singleton.h"
3
4using namespace thep_cpp_tools;
5using namespace std;
6
7
8int main()
9{
10  random_singleton* my_rnd;
11  my_rnd = random_singleton::get_instance( -1 );
12 
13  double* prob = new double[ 5 ];
14  prob[ 0 ] = 0.2; 
15  prob[ 1 ] = 0.2;
16  prob[ 2 ] = 0.2;
17  prob[ 3 ] = 0.2;
18  prob[ 4 ] = 0.2;
19  my_rnd->set_general_distribution_prob( 5, prob );
20  delete prob;
21
22  int antal[5];
23  antal[ 0 ] = 0;
24  antal[ 1 ] = 0;
25  antal[ 2 ] = 0;
26  antal[ 3 ] = 0;
27  antal[ 4 ] = 0;
28
29  for( size_t i = 0; i < 100; ++i )
30    antal[ my_rnd->get_rnd_discrete() ]++;
31
32  for( size_t i = 0; i < 5; ++i )
33    cout << i << ": " << antal[ i ] << endl;
34
35
36  delete my_rnd;
37
38  return 0;
39}
Note: See TracBrowser for help on using the repository browser.