File: testZiggurat.cc

package info (click to toggle)
clhep 2.1.4.1%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,012 kB
  • sloc: cpp: 50,094; sh: 6,694; makefile: 2,694; perl: 28
file content (63 lines) | stat: -rw-r--r-- 1,475 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//////////////////////////////////////////////////////////////////////////

#include <iostream>

#include "CLHEP/Random/RandGauss.h"
#include "CLHEP/Random/RandGaussQ.h"
#include "CLHEP/Random/RandExponential.h"
#include "CLHEP/Random/RandGaussZiggurat.h"
#include "CLHEP/Random/RandExpZiggurat.h"

//_________________________________________________________________________
int main() {

 std::ofstream output("testZiggurat.cout");  

 int ntest=10000000;

 output << "DEBUG: ntest="<<ntest<<std::endl;

 double sum_rnd1=0;
 for(int i=0;i<ntest;++i) {
   double g=CLHEP::RandGauss::shoot();
   sum_rnd1+=g;
 }  
 sum_rnd1/=ntest;
 output << "DEBUG: avg RandGauss="<<sum_rnd1<<std::endl;

 double sum_rnd2=0;
 for(int i=0;i<ntest;++i) {
   double g=CLHEP::RandGaussQ::shoot();
   sum_rnd2+=g;
 }  
 sum_rnd2/=ntest;
 output << "DEBUG: avg RandGaussQ="<<sum_rnd2<<std::endl;

 double sum_zig=0;
 for(int i=0;i<ntest;++i) {
   double g=CLHEP::RandGaussZiggurat::shoot();
    sum_zig+=g;
 }  
 sum_zig/=ntest;
 output << "DEBUG: avg RandGaussZiggurat="<<sum_zig<<std::endl;

 double sum_exp=0;
 for(int i=0;i<ntest;++i) {
   double g=CLHEP::RandExponential::shoot();
   sum_exp+=g;
 }  
 sum_exp/=ntest;
 output << "DEBUG: avg RandExponential="<<sum_exp<<std::endl;

 double sum_expZ=0;
 for(int i=0;i<ntest;++i) {
   double g=CLHEP::RandExpZiggurat::shoot();
   sum_expZ+=g;
 }  
 sum_expZ/=ntest;
 output << "DEBUG: avg RandExpZiggurat="<<sum_expZ<<std::endl;

 return 0;
}