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