Logo ROOT  
Reference Guide
testrandom.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_math
3/// \notebook -nodraw
4/// Performance test of all the ROOT random generator (TRandom, TRandom1, TRandom2 and TRandom3)
5/// Tests the generator TRandom3 against some ref values
6/// and creates a timing table against TRandom, TRandom1 and TRandom2.
7///
8/// E.g. on an an Intel Xeon Quad-core Harpertown (E5410) 2.33 GHz running
9/// Linux SLC4 64 bit and compiled with gcc 3.4
10///
11/// ~~~
12/// Distribution nanoseconds/call
13/// TRandom TRandom1 TRandom2 TRandom3
14/// Rndm.............. 5.000 105.000 7.000 10.000
15/// RndmArray......... 4.000 104.000 6.000 9.000
16/// Gaus.............. 36.000 180.000 40.000 48.000
17/// Rannor............ 118.000 220.000 120.000 124.000
18/// Landau............ 22.000 123.000 26.000 31.000
19/// Exponential....... 93.000 198.000 98.000 104.000
20/// Binomial(5,0.5)... 30.000 548.000 46.000 65.000
21/// Binomial(15,0.5).. 75.000 1615.000 125.000 178.000
22/// Poisson(3)........ 96.000 494.000 109.000 125.000
23/// Poisson(10)....... 138.000 1236.000 165.000 203.000
24/// Poisson(70)....... 818.000 1195.000 835.000 844.000
25/// Poisson(100)...... 837.000 1218.000 849.000 864.000
26/// GausTF1........... 83.000 180.000 87.000 88.000
27/// LandauTF1......... 80.000 180.000 83.000 86.000
28/// GausUNURAN........ 40.000 139.000 41.000 44.000
29/// PoissonUNURAN(10). 85.000 271.000 92.000 102.000
30/// PoissonUNURAN(100) 62.000 256.000 69.000 78.000
31/// ~~~
32///
33/// Note that this tutorial can be executed in interpreted or compiled mode
34///
35/// ~~~{.cpp}
36/// Root > .x testrandom.C
37/// Root > .x testrandom.C++
38/// ~~~
39///
40/// \macro_output
41/// \macro_code
42///
43/// \authors Rene Brun, Lorenzo Moneta
44
45#include <TRandom1.h>
46#include <TRandom2.h>
47#include <TRandom3.h>
48#include <TRandomGen.h>
49#include <TStopwatch.h>
50#include <TF1.h>
51#include <TUnuran.h>
52#include <TUnuranContDist.h>
53#include <TFile.h>
54
55
56void testAll() {
57 int i, N = 2000000;
58 float cpn = 1000000000./N;
59 int N1 = N/10; float cpn1 = cpn*10; // for TRandom1
60 double x,y;
61 TRandom *rsave = gRandom;
62 TRandom *r0 = new TRandom();
63 TRandom *r1 = new TRandom1();
64 TRandom *r2 = new TRandom2();
65 TRandom *r3 = new TRandom3();
66 TRandom *r4 = new TRandomMixMax();
67 TRandom *r5 = new TRandomMixMax17();
69 TRandom *r7 = new TRandomMixMax256();
71 TRandom *r9 = new TRandomMT64();
72 TRandom *r10 = new TRandomRanlux48();
73
74
75 TStopwatch sw;
76 printf("Distribution nanoseconds/call\n");
77 printf(" TRandom TRandom1 TRandom2 TRandom3 MixMax240 MixMax17 Mixmax256_0 MixMax256_2 MixMax256_4 MT_64 Ranlux48\n");
78
79 sw.Start();
80 for (i=0;i<N;i++) {
81 x = r0->Rndm(i);
82 }
83 printf("Rndm.............. %8.3f",sw.CpuTime()*cpn);
84 sw.Start();
85 for (i=0;i<N1;i++) {
86 x = r1->Rndm(i);
87 }
88 printf(" %8.3f",sw.CpuTime()*cpn1);
89 sw.Start();
90 for (i=0;i<N;i++) {
91 x = r2->Rndm(i);
92 }
93 printf(" %8.3f",sw.CpuTime()*cpn);
94 sw.Start();
95 for (i=0;i<N;i++) {
96 x = r3->Rndm(i);
97 }
98 printf(" %8.3f",sw.CpuTime()*cpn);
99 // new random generators
100
101 sw.Start();
102 for (i=0;i<N;i++) {
103 x = r4->Rndm(i);
104 }
105 printf(" %8.3f",sw.CpuTime()*cpn);
106
107 sw.Start();
108 for (i=0;i<N;i++) {
109 x = r5->Rndm(i);
110 }
111 printf(" %8.3f",sw.CpuTime()*cpn);
112
113 sw.Start();
114 for (i=0;i<N;i++) {
115 x = r6->Rndm(i);
116 }
117 printf(" %8.3f",sw.CpuTime()*cpn);
118
119 sw.Start();
120 for (i=0;i<N;i++) {
121 x = r7->Rndm(i);
122 }
123 printf(" %8.3f",sw.CpuTime()*cpn);
124
125 sw.Start();
126 for (i=0;i<N;i++) {
127 x = r8->Rndm(i);
128 }
129 printf(" %8.3f",sw.CpuTime()*cpn);
130
131 sw.Start();
132 for (i=0;i<N;i++) {
133 x = r9->Rndm(i);
134 }
135 printf(" %8.3f",sw.CpuTime()*cpn);
136
137 sw.Start();
138 for (i=0;i<N1;i++) {
139 x = r10->Rndm(i);
140 }
141 printf(" %8.3f",sw.CpuTime()*cpn1);
142
143 printf("\n\n");
144
145 // RNDMARRAY
146
147 const int NR = 1000;
148 double rn[NR];
149 sw.Start();
150 for (i=0;i<N;i+=NR) {
151 r0->RndmArray(NR,rn);
152 }
153 printf("RndmArray......... %8.3f",sw.CpuTime()*cpn);
154 sw.Start();
155 for (i=0;i<N1;i+=NR) {
156 r1->RndmArray(NR,rn);
157 }
158 printf(" %8.3f",sw.CpuTime()*cpn1);
159 sw.Start();
160 for (i=0;i<N;i+=NR) {
161 r2->RndmArray(NR,rn);
162 }
163 printf(" %8.3f",sw.CpuTime()*cpn);
164 sw.Start();
165 for (i=0;i<N;i+=NR) {
166 r3->RndmArray(NR,rn);
167 }
168 printf(" %8.3f",sw.CpuTime()*cpn);
169 sw.Start();
170 for (i=0;i<N;i+=NR) {
171 r4->RndmArray(NR,rn);
172 }
173 printf(" %8.3f",sw.CpuTime()*cpn);
174 sw.Start();
175 for (i=0;i<N;i+=NR) {
176 r5->RndmArray(NR,rn);
177 }
178 printf(" %8.3f",sw.CpuTime()*cpn);
179 sw.Start();
180 for (i=0;i<N;i+=NR) {
181 r6->RndmArray(NR,rn);
182 }
183 printf(" %8.3f",sw.CpuTime()*cpn);
184 sw.Start();
185 for (i=0;i<N;i+=NR) {
186 r7->RndmArray(NR,rn);
187 }
188 printf(" %8.3f",sw.CpuTime()*cpn);
189 sw.Start();
190 for (i=0;i<N;i+=NR) {
191 r8->RndmArray(NR,rn);
192 }
193 printf(" %8.3f",sw.CpuTime()*cpn);
194 sw.Start();
195 for (i=0;i<N;i+=NR) {
196 r9->RndmArray(NR,rn);
197 }
198 printf(" %8.3f",sw.CpuTime()*cpn);
199 sw.Start();
200 for (i=0;i<N1;i+=NR) {
201 r10->RndmArray(NR,rn);
202 }
203 printf(" %8.3f\n",sw.CpuTime()*cpn1);
204
205 // Gaus
206
207 sw.Start();
208 for (i=0;i<N;i++) {
209 x = r0->Gaus(0,1);
210 }
211 printf("Gaus.............. %8.3f",sw.CpuTime()*cpn);
212 sw.Start();
213 for (i=0;i<N1;i++) {
214 x = r1->Gaus(0,1);
215 }
216 printf(" %8.3f",sw.CpuTime()*cpn1);
217 sw.Start();
218 for (i=0;i<N;i++) {
219 x = r2->Gaus(0,1);
220 }
221 printf(" %8.3f",sw.CpuTime()*cpn);
222 sw.Start();
223 for (i=0;i<N;i++) {
224 x = r3->Gaus(0,1);
225 }
226 printf(" %8.3f",sw.CpuTime()*cpn);
227 sw.Start();
228 for (i=0;i<N;i++) {
229 x = r4->Gaus(0,1);
230 }
231 printf(" %8.3f",sw.CpuTime()*cpn);
232 sw.Start();
233 for (i=0;i<N;i++) {
234 x = r5->Gaus(0,1);
235 }
236 printf(" %8.3f",sw.CpuTime()*cpn);
237 sw.Start();
238 for (i=0;i<N;i++) {
239 x = r6->Gaus(0,1);
240 }
241 printf(" %8.3f",sw.CpuTime()*cpn);
242 sw.Start();
243 for (i=0;i<N;i++) {
244 x = r7->Gaus(0,1);
245 }
246 printf(" %8.3f",sw.CpuTime()*cpn);
247 sw.Start();
248 for (i=0;i<N;i++) {
249 x = r8->Gaus(0,1);
250 }
251 printf(" %8.3f",sw.CpuTime()*cpn);
252 sw.Start();
253 for (i=0;i<N;i++) {
254 x = r9->Gaus(0,1);
255 }
256 printf(" %8.3f\n",sw.CpuTime()*cpn);
257
258
259 // RANNOR
260
261 sw.Start();
262 for (i=0;i<N;i+=2) {
263 r0->Rannor(x,y);
264 }
265 printf("Rannor............ %8.3f",sw.CpuTime()*cpn);
266 sw.Start();
267 for (i=0;i<N1;i+=2) {
268 r1->Rannor(x,y);
269 }
270 printf(" %8.3f",sw.CpuTime()*cpn1);
271 sw.Start();
272 for (i=0;i<N;i+=2) {
273 r2->Rannor(x,y);
274 }
275 printf(" %8.3f",sw.CpuTime()*cpn);
276 sw.Start();
277 for (i=0;i<N;i+=2) {
278 r3->Rannor(x,y);
279 }
280 printf(" %8.3f",sw.CpuTime()*cpn);
281 sw.Start();
282 for (i=0;i<N;i+=2) {
283 r4->Rannor(x,y);
284 }
285 printf(" %8.3f",sw.CpuTime()*cpn);
286 sw.Start();
287 for (i=0;i<N;i+=2) {
288 r5->Rannor(x,y);
289 }
290 printf(" %8.3f",sw.CpuTime()*cpn);
291 sw.Start();
292 for (i=0;i<N;i+=2) {
293 r6->Rannor(x,y);
294 }
295 printf(" %8.3f",sw.CpuTime()*cpn);
296 sw.Start();
297 for (i=0;i<N;i+=2) {
298 r7->Rannor(x,y);
299 }
300 printf(" %8.3f",sw.CpuTime()*cpn);
301 sw.Start();
302 for (i=0;i<N;i+=2) {
303 r8->Rannor(x,y);
304 }
305 printf(" %8.3f",sw.CpuTime()*cpn);
306 sw.Start();
307 for (i=0;i<N;i+=2) {
308 r9->Rannor(x,y);
309 }
310 printf(" %8.3f\n",sw.CpuTime()*cpn);
311
312 // Landau
313
314 sw.Start();
315 for (i=0;i<N;i++) {
316 x = r0->Landau(0,1);
317 }
318 printf("Landau............ %8.3f",sw.CpuTime()*cpn);
319 sw.Start();
320 for (i=0;i<N1;i++) {
321 x = r1->Landau(0,1);
322 }
323 printf(" %8.3f",sw.CpuTime()*cpn1);
324 sw.Start();
325 for (i=0;i<N;i++) {
326 x = r2->Landau(0,1);
327 }
328 printf(" %8.3f",sw.CpuTime()*cpn);
329 sw.Start();
330 for (i=0;i<N;i++) {
331 x = r3->Landau(0,1);
332 }
333 printf(" %8.3f\n",sw.CpuTime()*cpn);
334
335 sw.Start();
336 for (i=0;i<N;i++) {
337 x = r0->Exp(1);
338 }
339 printf("Exponential....... %8.3f",sw.CpuTime()*cpn);
340 sw.Start();
341 for (i=0;i<N1;i++) {
342 x = r1->Exp(1);
343 }
344 printf(" %8.3f",sw.CpuTime()*cpn1);
345 sw.Start();
346 for (i=0;i<N;i++) {
347 x = r2->Exp(1);
348 }
349 printf(" %8.3f",sw.CpuTime()*cpn);
350 sw.Start();
351 for (i=0;i<N;i++) {
352 x = r3->Exp(1);
353 }
354 printf(" %8.3f\n",sw.CpuTime()*cpn);
355
356 sw.Start();
357 for (i=0;i<N;i++) {
358 x = r0->Binomial(5,0.5);
359 }
360 printf("Binomial(5,0.5)... %8.3f",sw.CpuTime()*cpn);
361 sw.Start();
362 for (i=0;i<N1;i++) {
363 x = r1->Binomial(5,0.5);
364 }
365 printf(" %8.3f",sw.CpuTime()*cpn1);
366 sw.Start();
367 for (i=0;i<N;i++) {
368 x = r2->Binomial(5,0.5);
369 }
370 printf(" %8.3f",sw.CpuTime()*cpn);
371 sw.Start();
372 for (i=0;i<N;i++) {
373 x = r3->Binomial(5,0.5);
374 }
375 printf(" %8.3f\n",sw.CpuTime()*cpn);
376
377 sw.Start();
378 for (i=0;i<N;i++) {
379 x = r0->Binomial(15,0.5);
380 }
381 printf("Binomial(15,0.5).. %8.3f",sw.CpuTime()*cpn);
382 sw.Start();
383 for (i=0;i<N1;i++) {
384 x = r1->Binomial(15,0.5);
385 }
386 printf(" %8.3f",sw.CpuTime()*cpn1);
387 sw.Start();
388 for (i=0;i<N;i++) {
389 x = r2->Binomial(15,0.5);
390 }
391 printf(" %8.3f",sw.CpuTime()*cpn);
392 sw.Start();
393 for (i=0;i<N;i++) {
394 x = r3->Binomial(15,0.5);
395 }
396 printf(" %8.3f\n",sw.CpuTime()*cpn);
397
398 sw.Start();
399 for (i=0;i<N;i++) {
400 x = r0->Poisson(3);
401 }
402 printf("Poisson(3)........ %8.3f",sw.CpuTime()*cpn);
403 sw.Start();
404 for (i=0;i<N1;i++) {
405 x = r1->Poisson(3);
406 }
407 printf(" %8.3f",sw.CpuTime()*cpn1);
408 sw.Start();
409 for (i=0;i<N;i++) {
410 x = r2->Poisson(3);
411 }
412 printf(" %8.3f",sw.CpuTime()*cpn);
413 sw.Start();
414 for (i=0;i<N;i++) {
415 x = r3->Poisson(3);
416 }
417 printf(" %8.3f\n",sw.CpuTime()*cpn);
418
419 sw.Start();
420 for (i=0;i<N;i++) {
421 x = r0->Poisson(10);
422 }
423 printf("Poisson(10)....... %8.3f",sw.CpuTime()*cpn);
424 sw.Start();
425 for (i=0;i<N1;i++) {
426 x = r1->Poisson(10);
427 }
428 printf(" %8.3f",sw.CpuTime()*cpn1);
429 sw.Start();
430 for (i=0;i<N;i++) {
431 x = r2->Poisson(10);
432 }
433 printf(" %8.3f",sw.CpuTime()*cpn);
434 sw.Start();
435 for (i=0;i<N;i++) {
436 x = r3->Poisson(10);
437 }
438 printf(" %8.3f\n",sw.CpuTime()*cpn);
439
440 sw.Start();
441 for (i=0;i<N;i++) {
442 x = r0->Poisson(70);
443 }
444 printf("Poisson(70)....... %8.3f",sw.CpuTime()*cpn);
445 sw.Start();
446 for (i=0;i<N1;i++) {
447 x = r1->Poisson(70);
448 }
449 printf(" %8.3f",sw.CpuTime()*cpn1);
450 sw.Start();
451 for (i=0;i<N;i++) {
452 x = r2->Poisson(70);
453 }
454 printf(" %8.3f",sw.CpuTime()*cpn);
455 sw.Start();
456 for (i=0;i<N;i++) {
457 x = r3->Poisson(70);
458 }
459 printf(" %8.3f\n",sw.CpuTime()*cpn);
460
461 sw.Start();
462 for (i=0;i<N;i++) {
463 x = r0->Poisson(100);
464 }
465 printf("Poisson(100)...... %8.3f",sw.CpuTime()*cpn);
466 sw.Start();
467 for (i=0;i<N1;i++) {
468 x = r1->Poisson(100);
469 }
470 printf(" %8.3f",sw.CpuTime()*cpn1);
471 sw.Start();
472 for (i=0;i<N;i++) {
473 x = r2->Poisson(100);
474 }
475 printf(" %8.3f",sw.CpuTime()*cpn);
476 sw.Start();
477 for (i=0;i<N;i++) {
478 x = r3->Poisson(100);
479 }
480 printf(" %8.3f\n",sw.CpuTime()*cpn);
481
482 TF1 *f1 = new TF1("f1","gaus",-4,4);
483 f1->SetParameters(1,0,1);
484 gRandom = r0;
485 sw.Start();
486 for (i=0;i<N;i++) {
487 x = f1->GetRandom();
488 }
489 printf("GausTF1........... %8.3f",sw.CpuTime()*cpn);
490 gRandom = r1;
491 sw.Start();
492 for (i=0;i<N;i++) {
493 x = f1->GetRandom();
494 }
495 printf(" %8.3f",sw.CpuTime()*cpn);
496 gRandom = r2;
497 sw.Start();
498 for (i=0;i<N;i++) {
499 x = f1->GetRandom();
500 }
501 printf(" %8.3f",sw.CpuTime()*cpn);
502 gRandom = r3;
503 sw.Start();
504 for (i=0;i<N;i++) {
505 x = f1->GetRandom();
506 }
507 printf(" %8.3f\n",sw.CpuTime()*cpn);
508
509 TF1 *f2 = new TF1("f2","landau",-5,15);
510 f2->SetParameters(1,0,1);
511
512 gRandom = r0;
513 sw.Start();
514 for (i=0;i<N;i++) {
515 x = f2->GetRandom();
516 }
517 printf("LandauTF1......... %8.3f",sw.CpuTime()*cpn);
518 gRandom = r1;
519 sw.Start();
520 for (i=0;i<N;i++) {
521 x = f2->GetRandom();
522 }
523 printf(" %8.3f",sw.CpuTime()*cpn);
524 gRandom = r2;
525 sw.Start();
526 for (i=0;i<N;i++) {
527 x = f2->GetRandom();
528 }
529 printf(" %8.3f",sw.CpuTime()*cpn);
530 gRandom = r3;
531 sw.Start();
532 for (i=0;i<N;i++) {
533 x = f2->GetRandom();
534 }
535 printf(" %8.3f\n",sw.CpuTime()*cpn);
536
537 // test using Unuran
538 TUnuran unr0(r0);
539 TUnuran unr1(r1);
540 TUnuran unr2(r2);
541 TUnuran unr3(r3);
542
543 // continuous distribution (ex. Gaus)
545 // use arou method (is probably the fastest)
546 unr0.Init(dist,"arou");
547 unr1.Init(dist,"arou");
548 unr2.Init(dist,"arou");
549 unr3.Init(dist,"arou");
550
551 sw.Start();
552 for (i=0;i<N;i++) {
553 x = unr0.Sample();
554 }
555 printf("GausUNURAN........ %8.3f",sw.CpuTime()*cpn);
556 sw.Start();
557 for (i=0;i<N;i++) {
558 x = unr1.Sample();
559 }
560 printf(" %8.3f",sw.CpuTime()*cpn);
561 sw.Start();
562 for (i=0;i<N;i++) {
563 x = unr2.Sample();
564 }
565 printf(" %8.3f",sw.CpuTime()*cpn);
566 sw.Start();
567 for (i=0;i<N;i++) {
568 x = unr3.Sample();
569 }
570 printf(" %8.3f\n",sw.CpuTime()*cpn);
571
572 // Poisson (nned to initialize before with Poisson mu value)
573
574 unr0.InitPoisson(10);
575 unr1.InitPoisson(10);
576 unr2.InitPoisson(10);
577 unr3.InitPoisson(10);
578
579 sw.Start();
580 for (i=0;i<N;i++) {
581 x = unr0.SampleDiscr();
582 }
583 printf("PoissonUNURAN(10). %8.3f",sw.CpuTime()*cpn);
584 sw.Start();
585 for (i=0;i<N;i++) {
586 x = unr1.SampleDiscr();
587 }
588 printf(" %8.3f",sw.CpuTime()*cpn);
589 sw.Start();
590 for (i=0;i<N;i++) {
591 x = unr2.SampleDiscr();
592 }
593 printf(" %8.3f",sw.CpuTime()*cpn);
594 sw.Start();
595 for (i=0;i<N;i++) {
596 x = unr3.SampleDiscr();
597 }
598 printf(" %8.3f\n",sw.CpuTime()*cpn);
599
600 unr0.InitPoisson(100);
601 unr1.InitPoisson(100);
602 unr2.InitPoisson(100);
603 unr3.InitPoisson(100);
604
605 sw.Start();
606 for (i=0;i<N;i++) {
607 x = unr0.SampleDiscr();
608 }
609 printf("PoissonUNURAN(100) %8.3f",sw.CpuTime()*cpn);
610 sw.Start();
611 for (i=0;i<N;i++) {
612 x = unr1.SampleDiscr();
613 }
614 printf(" %8.3f",sw.CpuTime()*cpn);
615 sw.Start();
616 for (i=0;i<N;i++) {
617 x = unr2.SampleDiscr();
618 }
619 printf(" %8.3f",sw.CpuTime()*cpn);
620 sw.Start();
621 for (i=0;i<N;i++) {
622 x = unr3.SampleDiscr();
623 }
624 printf(" %8.3f\n",sw.CpuTime()*cpn);
625
626
627 delete r0;
628 delete r1;
629 delete r2;
630 delete r3;
631 gRandom = rsave;
632
633#ifdef LATER
634 // Binomial
635 unr0.InitBinomial(15,0.5);
636 unr1.InitBinomial(15,0.5);
637 unr2.InitBinomial(15,0.5);
638 unr3.InitBinomial(15,0.5);
639
640 sw.Start();
641 for (i=0;i<N;i++) {
642 x = unr0.SampleDiscr();
643 }
644 printf("BinomialUN(15,0.5) %8.3f",sw.CpuTime()*cpn);
645 sw.Start();
646 for (i=0;i<N;i++) {
647 x = unr1.SampleDiscr();
648 }
649 printf(" %8.3f",sw.CpuTime()*cpn);
650 sw.Start();
651 for (i=0;i<N;i++) {
652 x = unr2.SampleDiscr();
653 }
654 printf(" %8.3f",sw.CpuTime()*cpn);
655 sw.Start();
656 for (i=0;i<N;i++) {
657 x = unr3.SampleDiscr();
658 }
659 printf(" %8.3f\n",sw.CpuTime()*cpn);
660#endif
661
662}
663
664int testRandom3() {
665
666 Float_t RefValue[] = // running using a seed of 4357 ROOT 5.13.07 and checked with GSL 1.8
667 { 0.999741749, 0.162909875, 0.282617805, 0.947201082, 0.231656543, 0.484973614, 0.957476957, 0.744305343,
668 0.540043658, 0.739952981, 0.759943798, 0.658636614, 0.315637622, 0.804403015, 0.519672115, 0.168572422,
669 0.47552973, 0.392313994, 0.221667687, 0.213190459,0.0303352042, 0.33353925, 0.194148851, 0.943716781,
670 0.579931675, 0.898304858, 0.665563931, 0.49861031, 0.560628257, 0.182284646, 0.296525531, 0.117408933,
671 0.0629176658, 0.648125575, 0.725418529, 0.637131158, 0.713885062,0.0995762432, 0.699267196, 0.10781247,
672 0.129242751, 0.502403039, 0.207779906, 0.288910306,0.0831747944, 0.128124215, 0.547371411,0.0823195996,
673 0.292141427, 0.891623737, 0.227117839, 0.431845463, 0.140733001, 0.400392135, 0.686946901, 0.170670911,
674 0.440820868, 0.045336565, 0.311296414, 0.506181051, 0.18241084, 0.511032015, 0.740788205, 0.365988627,
675 0.160808837, 0.460106785, 0.627836472, 0.677603688, 0.698196523, 0.478536868,0.0901075942, 0.338728522,
676 0.0952137967, 0.436541964, 0.474673352, 0.419245926, 0.777536852, 0.624610565, 0.98043655, 0.370430201,
677 0.830812636, 0.140806447, 0.744085307, 0.82973968, 0.391104318, 0.621956392, 0.346699478,0.0461695245,
678 0.613066321, 0.567374048, 0.498894026, 0.723802079, 0.144550525,0.0423031633, 0.310787023, 0.121641154,
679 0.242069671, 0.381058855, 0.440128537, 0.599795902, 0.644574654, 0.432626217, 0.555968262, 0.716841168,
680 0.642362515, 0.685776725,0.0961581462, 0.122933464,0.0569974151, 0.820072044, 0.125539286, 0.315745071,
681 0.180566925, 0.142227219, 0.664429613, 0.685189223, 0.191001933, 0.436343019, 0.964459225, 0.86816359,
682 0.130879965, 0.48444228, 0.374654451, 0.900475122, 0.178656787, 0.679635131, 0.62287431, 0.98365595,
683 0.44071478, 0.804737277, 0.994845061, 0.541550961, 0.255905455, 0.638945635, 0.57591027, 0.25872142,
684 0.191593001, 0.445663047, 0.149266509, 0.996723689, 0.121762222, 0.65153928,0.0277950978, 0.389977602,
685 0.827913044, 0.283813907, 0.610203644, 0.23641275, 0.41082105, 0.677714617, 0.847126588, 0.649256228,
686 0.0813826511, 0.120830484, 0.479199264, 0.777878358, 0.471977701, 0.943337511, 0.980800992, 0.334554731,
687 0.202667924, 0.342841234, 0.653544244, 0.682758797, 0.60993614,0.0999271029, 0.766254981, 0.735581528,
688 0.24113914, 0.263178711, 0.960869899, 0.423395737, 0.336058146,0.000249497825, 0.868841017,0.00375315035,
689 0.165846311,0.0118208411, 0.606455074, 0.729972019, 0.613824557, 0.965768184, 0.497098261, 0.529885403,
690 0.461607532, 0.713033701, 0.579959768, 0.682802555, 0.953921514,0.0236552036, 0.280110147, 0.869526353,
691 0.299333274, 0.319553603, 0.300951709, 0.941111486, 0.848127064, 0.753346129, 0.538244087, 0.408481381,
692 0.212371316,0.0761404021, 0.289934908,0.0197818337, 0.241247899, 0.384619165, 0.454906886, 0.373982521,
693 0.440188796, 0.117896808, 0.805429845, 0.164892641, 0.282529936, 0.172685399, 0.93584233, 0.68095306,
694 0.133696739, 0.254761223, 0.399444876, 0.369235365, 0.726361892, 0.277837459, 0.693569104, 0.500354689,
695 0.118405538, 0.151303335, 0.681446943, 0.720665918, 0.979646939, 0.696779111, 0.557210072, 0.680821482,
696 0.95535205, 0.598208956, 0.770453895, 0.913597486, 0.658958649, 0.670974613, 0.578185175, 0.95303929,
697 0.162923458, 0.335056986, 0.951824704, 0.109661644, 0.619302303, 0.956816742, 0.985243094,0.0707377489,
698 0.50233039, 0.680721226, 0.553320066, 0.587005581, 0.691620562, 0.46264791, 0.574254294, 0.072890088,
699 0.638266518, 0.387757288, 0.220960217,0.00223180233, 0.495656775, 0.191316523, 0.022265008, 0.903589021,
700 0.738628175, 0.44453089, 0.417702243, 0.760861122, 0.437753222, 0.190982861, 0.577112962, 0.132688343,
701 0.317824347, 0.48691649, 0.939091069, 0.933946281, 0.073660135, 0.612436295, 0.514748724, 0.624663582,
702 0.130645262, 0.645210441, 0.13414855, 0.652925968, 0.265210009, 0.381805269, 0.59021506, 0.669704082,
703 0.55433248,0.0195047602, 0.184346962, 0.991180462, 0.573677764, 0.637762085, 0.594857598, 0.515244688,
704 0.330693509, 0.39674245, 0.88396548, 0.771485266, 0.599075381,0.0247266297,0.0122587895, 0.698452319,
705 0.265991009, 0.736700721, 0.999972619, 0.749792316, 0.484955589, 0.823700529, 0.62277709, 0.902512094,
706 0.0565051287, 0.739077389, 0.37617622, 0.036800765, 0.776198219, 0.837354186, 0.34508193,0.0818426476,
707 0.222621545, 0.152476319, 0.401177195, 0.531612608, 0.811706602,0.0407775661, 0.117889008, 0.575189965,
708 0.832362208, 0.204641853, 0.238721773, 0.9969287, 0.258590596, 0.892055968, 0.846859788, 0.306583706,
709 0.0333624918, 0.706420498, 0.193615608, 0.508978138,0.0215451468, 0.672732793, 0.813562444, 0.807284052,
710 0.481526843, 0.537519095, 0.780848606, 0.335848908, 0.699259371, 0.425855299, 0.825240663, 0.945613692,
711 0.55484125, 0.710495188, 0.378360366, 0.648338731,0.0456727168, 0.155477323, 0.885353968, 0.721565725,
712 0.961667201, 0.430300885, 0.132031354, 0.439331209, 0.467187736, 0.410083217, 0.277196711, 0.278509559,
713 0.954620806, 0.804357491, 0.968510466, 0.999722791, 0.947160283, 0.248551138,0.0067049861, 0.444727315,
714 0.674048778, 0.496480361,0.0210092501, 0.831763222, 0.108545852,0.0931516394, 0.89020564, 0.445945211,
715 0.906906768, 0.554039821, 0.759434349, 0.815551384, 0.532968503,0.0551351462,0.0539856541, 0.89918819,
716 0.146907374, 0.482647314,0.0673029809, 0.281161865, 0.932849165, 0.507317933, 0.564503014, 0.8007132,
717 0.645887499, 0.309219498,0.0478066066, 0.25196583, 0.713881142, 0.670994017, 0.60528576, 0.148271899,
718 0.79525035, 0.665277353, 0.854302043, 0.810533677,0.0711439839,0.0687935678, 0.890466573, 0.758045957,
719 0.0703105873, 0.852094478, 0.775356902, 0.684895203, 0.234552787, 0.461575694, 0.936435457, 0.664946419,
720 0.45967959, 0.88782351, 0.574622261,0.0301686234, 0.767354721, 0.345478555, 0.609123143, 0.21754287,
721 0.643760561, 0.571392649, 0.802311049, 0.962335547, 0.401769856, 0.996553418, 0.745945812, 0.448411183,
722 0.39578428, 0.123389926, 0.532614913, 0.833379602, 0.91767313, 0.825607567, 0.4459154, 0.267136201,
723 0.6643989, 0.766860694, 0.665968275, 0.503955105, 0.835153702, 0.622405379, 0.457538918, 0.554983278,
724 0.36581371, 0.656302231, 0.917038669, 0.276054591, 0.121214441, 0.966178254, 0.697439008, 0.443547789,
725 0.630195824, 0.368346675, 0.238191956, 0.300273821, 0.710332172,0.0474748381, 0.492525443,0.0812539798,
726 0.122016782, 0.99310218, 0.355091027, 0.764863731, 0.904099543, 0.396109613, 0.817134856, 0.348974222,
727 0.266193634, 0.367501958, 0.752316213, 0.587800024, 0.489421095, 0.673474061, 0.328296139, 0.853945839,
728 0.832380736, 0.159588686, 0.322411022, 0.950173707, 0.095376712, 0.231019855, 0.860607752, 0.359627192,
729 0.984843699,0.0319756679, 0.828649914, 0.51680949, 0.489407924, 0.963977298, 0.960131739, 0.681816791,
730 0.860788169, 0.455829282, 0.332390656,0.0591498043, 0.452245977, 0.217354216, 0.34560744, 0.549971993,
731 0.317622252, 0.892976443, 0.49004545, 0.25647901, 0.968998638, 0.910636465, 0.226717598, 0.327828572,
732 0.28670209, 0.142515054,0.0992817392, 0.192332409, 0.308376869, 0.871415959, 0.391148786, 0.788660882,
733 0.200816041, 0.986475959, 0.882862126, 0.109862451, 0.354283255, 0.555742682, 0.690698458, 0.643815752,
734 0.363104285,0.0788627111, 0.200820414, 0.71697353, 0.744353746, 0.76763643, 0.245442451, 0.668009119,
735 0.886989377, 0.366849931, 0.531556628, 0.502843979, 0.31454367, 0.622541364,0.0199038582, 0.676355134,
736 0.429818622, 0.232835212, 0.987619457, 0.306572135, 0.494637038, 0.748614893, 0.891843561,0.0452854959,
737 0.427561072, 0.226978442, 0.484072985, 0.16464563,0.0898074883, 0.384263737,0.0238354723, 0.329734547,
738 0.531230736, 0.476683361, 0.877482474, 0.455501628, 0.497302495, 0.396184301, 0.886124728, 0.736070092,
739 0.108917595, 0.397921902, 0.842575021, 0.82620032, 0.936655165, 0.24558961, 0.639688616, 0.493335031,
740 0.0734495069, 0.780138101,0.0421121232, 0.701116477, 0.940523267, 0.70054817, 0.776760272, 0.192742581,
741 0.0069252688, 0.842983626, 0.919324176, 0.242083269, 0.190100674, 0.735084639, 0.164522319, 0.99030645,
742 0.98284794, 0.657169539,0.0187736442, 0.759596482, 0.357567611, 0.509016344, 0.738899681, 0.567923164,
743 0.289056634, 0.41501714, 0.981054561, 0.365884479, 0.517878261, 0.844209022, 0.968122653, 0.258894528,
744 0.478310441, 0.437340986, 0.379398001, 0.203081884, 0.550820748, 0.255542723, 0.550098031, 0.870477939,
745 0.241230214, 0.157108238, 0.218260827, 0.116277737, 0.749018275, 0.158290659, 0.476353907, 0.545327323,
746 0.878978121,0.0171442169, 0.542981987, 0.318018082, 0.788805343, 0.871721374, 0.738490409,0.0923330146,
747 0.301398643, 0.637103286, 0.571564271, 0.712810342, 0.644289242, 0.230476008, 0.971695586, 0.966159428,
748 0.291883909, 0.175285818, 0.312882552, 0.98465128, 0.568391354, 0.844468564, 0.144433908, 0.45994061,
749 0.607897905, 0.184122705, 0.342805493, 0.606432998, 0.838196585, 0.186188518,0.0302744689, 0.307391858,
750 0.125286029, 0.270394965, 0.874161481, 0.370509557, 0.89423337, 0.407995674, 0.881878469, 0.647951238,
751 0.236986727, 0.528807336, 0.293731542,0.0943204253, 0.934538626, 0.121679332, 0.34968176,0.0670268578,
752 0.642196769, 0.692447138, 0.334926733, 0.374244194, 0.313885051, 0.538738295, 0.098592523, 0.490514225,
753 0.32873567, 0.709725794, 0.88169803, 0.393000481, 0.854243273, 0.463776593, 0.52705639, 0.493309892,
754 0.267784336, 0.583077476,0.0573514167, 0.959336368, 0.771417173,0.0427184631, 0.498433369,0.0522942701,
755 0.56155145, 0.960361909, 0.619817314, 0.528628368, 0.698235179, 0.186162042, 0.553998168, 0.666120292,
756 0.152731049, 0.948750157, 0.186825789, 0.580512664, 0.851024442, 0.106865844, 0.675861737, 0.79604524,
757 0.657646103,0.00934952381, 0.206267588, 0.636420368,0.0382564603, 0.67771025, 0.677917925, 0.671684269,
758 0.396317716, 0.661597047, 0.633360383, 0.962124239, 0.992711418,0.0993448263,0.0678932741, 0.426013152,
759 0.947045502, 0.708326009, 0.466817846,0.0448362886, 0.748580922, 0.678370694, 0.210921343, 0.398490306,
760 0.953675585,0.0289022848, 0.935766569, 0.846930474, 0.662760176, 0.867910903, 0.652359324, 0.45280494,
761 0.305228982, 0.352034987, 0.279643402, 0.236045594,0.0270034608, 0.652062389, 0.712000227, 0.619930867,
762 0.125439078, 0.452789963, 0.92233151, 0.120844359, 0.403808975, 0.260290446, 0.778843638, 0.6678412,
763 0.0267894373, 0.491332301, 0.915060888, 0.704025347, 0.628200853, 0.578338467, 0.629156416, 0.730410649,
764 0.641318334, 0.463709335, 0.614291239, 0.254470656, 0.808682692, 0.22898373, 0.450477996, 0.874235142,
765 0.202773906, 0.523711192, 0.126518266, 0.579402899, 0.26188467, 0.207769057, 0.55283816, 0.851395364,
766 0.513594437, 0.558259845, 0.666148535, 0.998974657, 0.178274074, 0.116739636,0.0684255431, 0.622713377,
767 0.31448295, 0.889827933, 0.80647766, 0.429916949, 0.524695458, 0.45267553, 0.630743121, 0.566594485,
768 0.958860663, 0.908052286, 0.700898262, 0.377025384, 0.683796226, 0.198088462, 0.617400699, 0.413726158,
769 0.823588417, 0.755577948, 0.703097317, 0.364294278, 0.819786986, 0.751581763, 0.048769509, 0.528569003,
770 0.616748192, 0.270942831, 0.800841747, 0.235174223, 0.903786552, 0.258801569, 0.191336412, 0.012410342,
771 0.853413998, 0.621008712, 0.855861931, 0.140106201, 0.872687964, 0.708839735,0.0926409892,0.0207504195,
772 0.782636518,0.0300825236, 0.504610632,0.0816221782, 0.773493745, 0.872577282, 0.880031248, 0.883524299,
773 0.872427328, 0.458722225, 0.902298841, 0.547904952,0.0559884352, 0.591179888, 0.563941709, 0.776130076,
774 0.295569778,0.0408536533, 0.398567183, 0.28227462, 0.806716321, 0.507159362, 0.688150965, 0.49466404,
775 0.45454604, 0.421480091,0.0392517329,0.0911962031, 0.393815309, 0.135373195, 0.968650583, 0.811676111,
776 0.325965411, 0.961999178, 0.100281202, 0.102924612, 0.30725909, 0.33368206, 0.857966134, 0.522921736,
777 0.615500041, 0.981558684, 0.797484739, 0.198809674, 0.45670419, 0.570970797, 0.214908696, 0.686433314,
778 0.278602115, 0.179739848, 0.397497946, 0.162858935, 0.802621762,0.0836459133, 0.638270752, 0.230856518,
779 0.580094379, 0.864292514, 0.932738287, 0.821393124, 0.480590473, 0.636373016, 0.181508656, 0.469200501,
780 0.309276441, 0.668810431, 0.722341161, 0.574856669, 0.527854513, 0.809231559, 0.986882661, 0.323860496,
781 0.606396459, 0.759558966, 0.79096818,0.0699298142, 0.550465414,0.00929828244, 0.784629475, 0.689044114,
782 0.963588091, 0.516441598, 0.357178305, 0.482336892, 0.429959602, 0.996306147, 0.601176011, 0.785004207,
783 0.970542121, 0.487854549,0.0949267522, 0.979331773, 0.120877739, 0.630260336, 0.19424754, 0.213081703,
784 0.0145987798, 0.366671115, 0.340100777, 0.721786347, 0.367533113,0.0210335371, 0.131687992, 0.586759676,
785 0.73360464, 0.863635151, 0.136994646,0.0524269778, 0.406223408, 0.241656947, 0.472450703, 0.872215979,
786 0.454719233,0.0715790696, 0.314061244, 0.492823114, 0.741721134, 0.694783663, 0.982867872, 0.319748137,
787 0.804203704,0.0534678153, 0.746155348, 0.303474931,0.0930815139, 0.934531664, 0.746868186, 0.100048471,
788 0.720296508, 0.21075374, 0.96309675, 0.749189411, 0.739621932, 0.510072327,0.0872929865, 0.650020469,
789 0.0823648495, 0.726920745, 0.532618265, 0.749305866, 0.86126694,0.0346994482,0.0931224583, 0.655257095,
790 0.959517847, 0.487057231, 0.859895745, 0.084794421, 0.718541715, 0.850918328, 0.818884782, 0.71627446,
791 0.40822393, 0.63658567, 0.523838703, 0.372038872, 0.353426097, 0.598049047,0.0974868746, 0.276353038
792 };
793
794 Int_t rc1 = 0;
795 Int_t rc2 = 0;
796 TRandom3 r(4357);
797 Float_t x;
798 Int_t i;
799
800 // check whether the sequence is ok or not
801 for (i=0;i<1000;i++) {
802 x = r.Rndm();
803 // printf("%e ",x-RefValue[i]); if(i%8==7) printf("\n");
804 if (TMath::Abs(x-RefValue[i]) > 10e-8) {
805 printf("i=%d x=%.8f but should be %.8f\n",i,x,RefValue[i]);
806 rc1 += 1;
807 }
808 }
809
810 // check whether a state can be saved and restored
811 TFile *file = new TFile("random3.root","RECREATE");
812 file->SetCompressionLevel(0);
813 r.Write("r");
814 delete file;
815 file = new TFile("random3.root");
816 TRandom3 *rs = (TRandom3*) file->Get("r");
817 for (i=0;i<1000;i++) {
818 if (r.Rndm() - rs->Rndm() != 0) rc2 += 1;
819 }
820 if (rc2 != 0) printf("state restoration failed\n");
821
822 return rc1 + rc2;
823}
824
825
826void testrandom()
827{
828 testRandom3();
829 testAll();
830}
ROOT::R::TRInterface & r
Definition: Object.C:4
#define e(i)
Definition: RSha256.hxx:103
int Int_t
Definition: RtypesCore.h:43
float Float_t
Definition: RtypesCore.h:55
#define N
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
1-Dim function class
Definition: TF1.h:210
virtual Double_t GetRandom()
Return a random number following this function shape.
Definition: TF1.cxx:2077
virtual void SetParameters(const Double_t *params)
Definition: TF1.h:638
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:53
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TObject.cxx:796
The Ranlux Random number generator class.
Definition: TRandom1.h:27
Random number generator class based on the maximally quidistributed combined Tausworthe generator by ...
Definition: TRandom2.h:27
Random number generator class based on M.
Definition: TRandom3.h:27
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandom3.cxx:100
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandomGen.h:60
virtual void RndmArray(Int_t n, Float_t *array)
Return an array of n random numbers uniformly distributed in ]0,1].
Definition: TRandomGen.h:61
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Definition: TRandom.cxx:263
virtual void RndmArray(Int_t n, Float_t *array)
Return an array of n random numbers uniformly distributed in ]0,1].
Definition: TRandom.cxx:577
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
Definition: TRandom.cxx:391
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
Definition: TRandom.cxx:489
virtual Double_t Exp(Double_t tau)
Returns an exponential deviate.
Definition: TRandom.cxx:240
virtual Double_t Landau(Double_t mean=0, Double_t sigma=1)
Generate a random number following a Landau distribution with location parameter mu and scale paramet...
Definition: TRandom.cxx:369
virtual Int_t Binomial(Int_t ntot, Double_t prob)
Generates a random integer N according to the binomial law.
Definition: TRandom.cxx:200
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandom.cxx:541
Stopwatch class.
Definition: TStopwatch.h:28
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition: TStopwatch.cxx:58
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
Definition: TStopwatch.cxx:125
TUnuranContDist class describing one dimensional continuous distribution.
TUnuran class.
Definition: TUnuran.h:79
TRandomGen< ROOT::Math::MixMaxEngine< 240, 0 > > TRandomMixMax
MIXMAX generator based on a state of N=240.
Definition: TRandomGen.h:100
TRandomGen< ROOT::Math::StdEngine< std::mt19937_64 > > TRandomMT64
Generator based on a the Mersenne-Twister generator with 64 bits, using the implementation provided b...
Definition: TRandomGen.h:133
TRandomGen< ROOT::Math::MixMaxEngine< 256, 2 > > TRandomMixMax256
MIXMAX generator based on a state of N=256, based on the generator descrived in this paper:
Definition: TRandomGen.h:125
TRandomGen< ROOT::Math::MixMaxEngine< 17, 0 > > TRandomMixMax17
MIXMAX generator based on a state of N=17.
Definition: TRandomGen.h:111
TRandomGen< ROOT::Math::StdEngine< std::ranlux48 > > TRandomRanlux48
Generator based on a the RanLux generator with 48 bits, using the implementation provided by the stan...
Definition: TRandomGen.h:141
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
TF1 * f1
Definition: legend1.C:11
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
Definition: file.py:1