1 /*
2 file automatically generated by make_test_files.pl
3 Tue Apr 19 14:01:03 2011
4 */
5
6 /*****************************************************************************
7 * *
8 * UNU.RAN -- Universal Non-Uniform Random number generator *
9 * *
10 *****************************************************************************/
11
12 /**
13 ** Tests for MVTDR
14 **/
15
16 /*---------------------------------------------------------------------------*/
17 #include "testunuran.h"
18
19 #ifdef UNUR_URNG_DEFAULT_RNGSTREAM
20 #include <RngStream.h>
21 #endif
22 /*---------------------------------------------------------------------------*/
23
24 /*---------------------------------------------------------------------------*/
25 /* global variables */
26
27 static FILE *TESTLOG; /* test log file */
28 static FILE *UNURANLOG; /* unuran log file */
29
30 static int test_ok = TRUE; /* all tests ok (boolean) */
31 static int fullcheck = FALSE; /* whether all checks are performed */
32
33 static TIMER watch; /* stop watch */
34
35 /*---------------------------------------------------------------------------*/
36
37 void run_verify_generator( FILE *LOG, int line, UNUR_PAR *par );
38
39
40
41 /*---------------------------------------------------------------------------*/
42
43 void test_new (void);
44 void test_set (void);
45 void test_get (void);
46 void test_chg (void);
47 void test_init (void);
48 void test_reinit (void);
49 void test_sample (void);
50 void test_validate (void);
51 void test_special(void);
52
53 /*---------------------------------------------------------------------------*/
54
55
56
57 /* prototypes */
58
59 int unur_mvtdr_set_pedantic( UNUR_PAR *par, int pedantic );
60
61 #define COMPARE_SAMPLE_SIZE (9999)
62 #define VIOLATE_SAMPLE_SIZE (20)
63
64 double pdf_normal(const double *coord, UNUR_DISTR *distr);
65 int dpdf_normal(double *grad, const double *coord, UNUR_DISTR *distr);
66
67 double logpdf_normal(const double *coord, UNUR_DISTR *distr);
68 int dlogpdf_normal(double *grad, const double *coord, UNUR_DISTR *distr);
69
70
71 /* we need marginal distributions for the chi2 tests */
72 #define unur_distr_multicauchy unur_distr_multicauchy_w_marginals
73 #define unur_distr_multinormal unur_distr_multinormal_w_marginals
74 #define unur_distr_multistudent unur_distr_multistudent_w_marginals
75
76
77
78
79
80 /*---------------------------------------------------------------------------*/
81
82 #ifndef CHI2_FAILURES_TOLERATED
83 # define CHI2_FAILURES_TOLERATED DEFAULT_CHI2_FAILURES_TOLERATED
84 #endif
85
86 /*---------------------------------------------------------------------------*/
87 /* [verbatim] */
88
89
90
91 /* dummy function */
unur_mvtdr_set_pedantic(UNUR_PAR * par ATTRIBUTE__UNUSED,int pedantic ATTRIBUTE__UNUSED)92 int unur_mvtdr_set_pedantic( UNUR_PAR *par ATTRIBUTE__UNUSED, int pedantic ATTRIBUTE__UNUSED)
93 { return 1; }
94
95 /*-----------------------------------------------------------------*/
96
pdf_normal(const double * coord,UNUR_DISTR * distr ATTRIBUTE__UNUSED)97 double pdf_normal(const double *coord, UNUR_DISTR *distr ATTRIBUTE__UNUSED)
98 /* multinormal density function */
99 {
100 int i;
101 double f = 0.;
102
103 for( i=0; i<3; i++ )
104 f += coord[i] * coord[i];
105
106 return( exp(-f) );
107 } /* end of pdf_normal() */
108
109
dpdf_normal(double * grad,const double * coord,UNUR_DISTR * distr ATTRIBUTE__UNUSED)110 int dpdf_normal(double *grad, const double *coord, UNUR_DISTR *distr ATTRIBUTE__UNUSED)
111 /* gradient of multinormal density function */
112 {
113 int i;
114 double f = 0.;
115
116 /* d(e^{-\sum j*x_j^2})/d x_i = -2*x_i*e^{-\sum j*x_j^2} */
117
118 for( i=0; i<3; i++ )
119 f += coord[i] * coord[i];
120 f = exp( -f );
121
122 for( i=0; i<3; i++ )
123 grad[i] = (-2) * coord[i] * f;
124
125 return 0;
126
127 } /* end of dpdf_normal() */
128
129
130 /*-----------------------------------------------------------------*/
131
logpdf_normal(const double * coord,UNUR_DISTR * distr ATTRIBUTE__UNUSED)132 double logpdf_normal(const double *coord, UNUR_DISTR *distr ATTRIBUTE__UNUSED)
133 /* multinormal density function */
134 {
135 int i;
136 double f = 0.;
137
138 for( i=0; i<3; i++ )
139 f += coord[i] * coord[i];
140
141 return (-f);
142 } /* end of logpdf_normal() */
143
144
dlogpdf_normal(double * grad,const double * coord,UNUR_DISTR * distr ATTRIBUTE__UNUSED)145 int dlogpdf_normal(double *grad, const double *coord, UNUR_DISTR *distr ATTRIBUTE__UNUSED)
146 /* gradient of multinormal density function */
147 {
148 int i;
149
150 /* d(e^{-\sum j*x_j^2})/d x_i = -2*i*x_i*e^{-\sum j*x_j^2} */
151
152 for( i=0; i<3; i++ )
153 grad[i] = -2 * coord[i];
154
155 return 0;
156
157 } /* end of dlogpdf_normal() */
158
159 /*---------------------------------------------------------------------------*/
160 /* [new] */
161
test_new(void)162 void test_new (void)
163 {
164 int n_tests_failed; /* number of failed tests */
165
166 /* start test */
167 printf("[new "); fflush(stdout);
168 fprintf(TESTLOG,"\n[new]\n");
169
170 /* reset counter */
171 n_tests_failed = 0;
172
173 /* set stop watch */
174 stopwatch_lap(&watch);
175
176 { /* invalid NULL ptr */
177 UNUR_DISTR *distr = NULL;
178 distr = NULL;
179
180
181 unur_reset_errno();
182 n_tests_failed += (check_expected_NULL(TESTLOG,41,(unur_mvtdr_new( distr )))==UNUR_SUCCESS)?0:1;
183 n_tests_failed += (check_errorcode(TESTLOG,41,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
184 unur_distr_free(distr);
185 }
186
187 { /* invalid distribution type */
188 UNUR_DISTR *distr = NULL;
189 distr = unur_distr_discr_new();
190
191
192 unur_reset_errno();
193 n_tests_failed += (check_expected_NULL(TESTLOG,48,(unur_mvtdr_new( distr )))==UNUR_SUCCESS)?0:1;
194 n_tests_failed += (check_errorcode(TESTLOG,48,UNUR_ERR_DISTR_INVALID)==UNUR_SUCCESS)?0:1;
195 unur_distr_free(distr);
196 }
197
198 { /* invalid number of dimensions */
199 UNUR_DISTR *distr = NULL;
200 distr = unur_distr_cvec_new(1);
201
202
203 unur_reset_errno();
204 n_tests_failed += (check_expected_NULL(TESTLOG,54,(unur_mvtdr_new( distr )))==UNUR_SUCCESS)?0:1;
205 n_tests_failed += (check_errorcode(TESTLOG,54,UNUR_ERR_DISTR_PROP)==UNUR_SUCCESS)?0:1;
206 unur_distr_free(distr);
207 }
208
209 { /* missing data */
210 UNUR_DISTR *distr = NULL;
211 distr = unur_distr_cvec_new(3);
212
213
214 unur_reset_errno();
215 n_tests_failed += (check_expected_NULL(TESTLOG,61,(unur_mvtdr_new( distr )))==UNUR_SUCCESS)?0:1;
216 n_tests_failed += (check_errorcode(TESTLOG,61,UNUR_ERR_DISTR_REQUIRED)==UNUR_SUCCESS)?0:1;
217 unur_distr_free(distr);
218 }
219
220 { /* missing data */
221 UNUR_DISTR *distr = NULL;
222 distr = unur_distr_cvec_new(3);
223 unur_distr_cvec_set_pdf(distr,pdf_normal);
224
225
226 unur_reset_errno();
227 n_tests_failed += (check_expected_NULL(TESTLOG,69,(unur_mvtdr_new( distr )))==UNUR_SUCCESS)?0:1;
228 n_tests_failed += (check_errorcode(TESTLOG,69,UNUR_ERR_DISTR_REQUIRED)==UNUR_SUCCESS)?0:1;
229 unur_distr_free(distr);
230 }
231
232 { /* missing data */
233 UNUR_DISTR *distr = NULL;
234 distr = unur_distr_cvec_new(3);
235 unur_distr_cvec_set_logpdf(distr,logpdf_normal);
236
237
238 unur_reset_errno();
239 n_tests_failed += (check_expected_NULL(TESTLOG,77,(unur_mvtdr_new( distr )))==UNUR_SUCCESS)?0:1;
240 n_tests_failed += (check_errorcode(TESTLOG,77,UNUR_ERR_DISTR_REQUIRED)==UNUR_SUCCESS)?0:1;
241 unur_distr_free(distr);
242 }
243
244
245 /* timing */
246 stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
247
248 /* test finished */
249 test_ok &= (n_tests_failed) ? 0 : 1;
250 (n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
251
252 } /* end of test_new() */
253
254 /*---------------------------------------------------------------------------*/
255 /* [set] */
256
test_set(void)257 void test_set (void)
258 {
259 int n_tests_failed; /* number of failed tests */
260
261 /* start test */
262 printf("[set "); fflush(stdout);
263 fprintf(TESTLOG,"\n[set]\n");
264
265 /* reset counter */
266 n_tests_failed = 0;
267
268 /* set stop watch */
269 stopwatch_lap(&watch);
270
271 { /* invalid NULL ptr */
272 UNUR_PAR *par = NULL;
273 par = NULL;
274
275
276 unur_reset_errno();
277 n_tests_failed += (check_expected_setfailed(TESTLOG,89,(unur_mvtdr_set_stepsmin( par, 5 )))==UNUR_SUCCESS)?0:1;
278 n_tests_failed += (check_errorcode(TESTLOG,89,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
279
280 unur_reset_errno();
281 n_tests_failed += (check_expected_setfailed(TESTLOG,92,(unur_mvtdr_set_maxcones( par, 5000 )))==UNUR_SUCCESS)?0:1;
282 n_tests_failed += (check_errorcode(TESTLOG,92,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
283
284 unur_reset_errno();
285 n_tests_failed += (check_expected_setfailed(TESTLOG,95,(unur_mvtdr_set_verify( par, 1 )))==UNUR_SUCCESS)?0:1;
286 n_tests_failed += (check_errorcode(TESTLOG,95,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
287 }
288
289 { /* invalid parameter object */
290 UNUR_DISTR *distr = NULL;
291 UNUR_PAR *par = NULL;
292 distr = unur_distr_normal(NULL,0);
293 par = unur_arou_new(distr);
294
295
296 unur_reset_errno();
297 n_tests_failed += (check_expected_setfailed(TESTLOG,103,(unur_mvtdr_set_stepsmin( par, 5 )))==UNUR_SUCCESS)?0:1;
298 n_tests_failed += (check_errorcode(TESTLOG,103,UNUR_ERR_PAR_INVALID)==UNUR_SUCCESS)?0:1;
299
300 unur_reset_errno();
301 n_tests_failed += (check_expected_setfailed(TESTLOG,106,(unur_mvtdr_set_maxcones( par, 5000 )))==UNUR_SUCCESS)?0:1;
302 n_tests_failed += (check_errorcode(TESTLOG,106,UNUR_ERR_PAR_INVALID)==UNUR_SUCCESS)?0:1;
303
304 unur_reset_errno();
305 n_tests_failed += (check_expected_setfailed(TESTLOG,109,(unur_mvtdr_set_verify( par, 1 )))==UNUR_SUCCESS)?0:1;
306 n_tests_failed += (check_errorcode(TESTLOG,109,UNUR_ERR_PAR_INVALID)==UNUR_SUCCESS)?0:1;
307 unur_par_free(par);
308 unur_distr_free(distr);
309 }
310
311 { /* invalid parameters */
312 UNUR_DISTR *distr = NULL;
313 UNUR_PAR *par = NULL;
314 distr = unur_distr_multinormal( 3, NULL, NULL );
315 par = unur_mvtdr_new(distr);
316
317
318 unur_reset_errno();
319 n_tests_failed += (check_expected_setfailed(TESTLOG,119,(unur_mvtdr_set_stepsmin( par, -1 )))==UNUR_SUCCESS)?0:1;
320 n_tests_failed += (check_errorcode(TESTLOG,119,UNUR_ERR_PAR_SET)==UNUR_SUCCESS)?0:1;
321 unur_par_free(par);
322 unur_distr_free(distr);
323 }
324
325
326 /* timing */
327 stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
328
329 /* test finished */
330 test_ok &= (n_tests_failed) ? 0 : 1;
331 (n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
332
333 } /* end of test_set() */
334
335 /*---------------------------------------------------------------------------*/
336 /* [get] */
337
test_get(void)338 void test_get (void)
339 {
340 int n_tests_failed; /* number of failed tests */
341
342 /* start test */
343 printf("[get "); fflush(stdout);
344 fprintf(TESTLOG,"\n[get]\n");
345
346 /* reset counter */
347 n_tests_failed = 0;
348
349 /* set stop watch */
350 stopwatch_lap(&watch);
351
352 { /* invalid NULL ptr */
353 UNUR_GEN *gen = NULL;
354 gen = NULL;
355
356
357 unur_reset_errno();
358 n_tests_failed += (check_expected_INFINITY(TESTLOG,132,(unur_mvtdr_get_hatvol(gen)))==UNUR_SUCCESS)?0:1;
359 n_tests_failed += (check_errorcode(TESTLOG,132,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
360
361 unur_reset_errno();
362 n_tests_failed += (check_expected_zero(TESTLOG,135,(unur_mvtdr_get_ncones(gen)))==UNUR_SUCCESS)?0:1;
363 n_tests_failed += (check_errorcode(TESTLOG,135,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
364 unur_free(gen);
365 }
366
367 { /* invalid generator object */
368 UNUR_DISTR *distr = NULL;
369 UNUR_PAR *par = NULL;
370 UNUR_GEN *gen = NULL;
371 distr = unur_distr_normal(NULL,0);
372 par = unur_arou_new(distr);
373 gen = unur_init(par);
374 abort_if_NULL(TESTLOG, 140, gen );
375
376
377 unur_reset_errno();
378 n_tests_failed += (check_expected_INFINITY(TESTLOG,144,(unur_mvtdr_get_hatvol(gen)))==UNUR_SUCCESS)?0:1;
379 n_tests_failed += (check_errorcode(TESTLOG,144,UNUR_ERR_GEN_INVALID)==UNUR_SUCCESS)?0:1;
380
381 unur_reset_errno();
382 n_tests_failed += (check_expected_zero(TESTLOG,147,(unur_mvtdr_get_ncones(gen)))==UNUR_SUCCESS)?0:1;
383 n_tests_failed += (check_errorcode(TESTLOG,147,UNUR_ERR_GEN_INVALID)==UNUR_SUCCESS)?0:1;
384 unur_distr_free(distr);
385 unur_free(gen);
386 }
387
388
389 /* timing */
390 stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
391
392 /* test finished */
393 test_ok &= (n_tests_failed) ? 0 : 1;
394 (n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
395
396 } /* end of test_get() */
397
398 /*---------------------------------------------------------------------------*/
399 /* [chg] */
400
test_chg(void)401 void test_chg (void)
402 {
403 int n_tests_failed; /* number of failed tests */
404
405 /* start test */
406 printf("[chg "); fflush(stdout);
407 fprintf(TESTLOG,"\n[chg]\n");
408
409 /* reset counter */
410 n_tests_failed = 0;
411
412 /* set stop watch */
413 stopwatch_lap(&watch);
414
415 { /* invalid generator object */
416 UNUR_GEN *gen = NULL;
417 gen = NULL;
418
419
420 unur_reset_errno();
421 n_tests_failed += (check_expected_setfailed(TESTLOG,158,(unur_mvtdr_chg_verify(gen,1)))==UNUR_SUCCESS)?0:1;
422 n_tests_failed += (check_errorcode(TESTLOG,158,UNUR_ERR_NULL)==UNUR_SUCCESS)?0:1;
423 unur_free(gen);
424 }
425
426 { /* invalid generator object */
427 UNUR_DISTR *distr = NULL;
428 UNUR_PAR *par = NULL;
429 UNUR_GEN *gen = NULL;
430 double fpar[2] = {0.,1.};
431 distr = unur_distr_normal(fpar,2);
432 par = unur_srou_new(distr);
433 unur_set_debug(par,0);
434 gen = unur_init( par );
435 abort_if_NULL(TESTLOG, 165, gen );
436
437
438 unur_reset_errno();
439 n_tests_failed += (check_expected_setfailed(TESTLOG,169,(unur_mvtdr_chg_verify(gen,1)))==UNUR_SUCCESS)?0:1;
440 n_tests_failed += (check_errorcode(TESTLOG,169,UNUR_ERR_GEN_INVALID)==UNUR_SUCCESS)?0:1;
441 unur_distr_free(distr);
442 unur_free(gen);
443 }
444
445
446 /* timing */
447 stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
448
449 /* test finished */
450 test_ok &= (n_tests_failed) ? 0 : 1;
451 (n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
452
453 } /* end of test_chg() */
454
455 /*---------------------------------------------------------------------------*/
456 /* [reinit] */
457
test_reinit(void)458 void test_reinit (void)
459 {
460 int n_tests_failed; /* number of failed tests */
461
462 /* start test */
463 printf("[reinit "); fflush(stdout);
464 fprintf(TESTLOG,"\n[reinit]\n");
465
466 /* reset counter */
467 n_tests_failed = 0;
468
469 /* set stop watch */
470 stopwatch_lap(&watch);
471
472 { /* does not exist */
473 UNUR_DISTR *distr = NULL;
474 UNUR_PAR *par = NULL;
475 UNUR_GEN *gen = NULL;
476 double x[3];
477 distr = unur_distr_multinormal(3,NULL,NULL);
478 par = unur_mvtdr_new(distr);
479 gen = unur_init( par );
480 abort_if_NULL(TESTLOG, 183, gen );
481
482
483 unur_reset_errno();
484 n_tests_failed += (check_expected_setfailed(TESTLOG,187,(unur_reinit( gen )))==UNUR_SUCCESS)?0:1;
485 n_tests_failed += (check_errorcode(TESTLOG,187,UNUR_ERR_NO_REINIT)==UNUR_SUCCESS)?0:1;
486
487 unur_reset_errno();
488 unur_sample_vec( gen, x );
489 n_tests_failed += (check_expected_INFINITY(TESTLOG,191,(x[0]))==UNUR_SUCCESS)?0:1;
490 n_tests_failed += (check_errorcode(TESTLOG,191,UNUR_ERR_GEN_CONDITION)==UNUR_SUCCESS)?0:1;
491 unur_distr_free(distr);
492 unur_free(gen);
493 }
494
495
496 /* timing */
497 stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
498
499 /* test finished */
500 test_ok &= (n_tests_failed) ? 0 : 1;
501 (n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
502
503 } /* end of test_reinit() */
504
505 /*---------------------------------------------------------------------------*/
506 /* [sample] */
507
test_sample(void)508 void test_sample (void)
509 {
510 int n_tests_failed; /* number of failed tests */
511
512 /* start test */
513 printf("[sample "); fflush(stdout);
514 fprintf(TESTLOG,"\n[sample]\n");
515
516 /* reset counter */
517 n_tests_failed = 0;
518
519 /* set stop watch */
520 stopwatch_lap(&watch);
521
522 { /* test clone */
523 UNUR_DISTR *distr = NULL;
524 UNUR_PAR *par = NULL;
525 UNUR_GEN *gen = NULL;
526 const int dim = 3;
527 double mean[] = {1.,2.,3.};
528 double covar[] = { 2., 2., 1., 2., 4., 3., 1., 3., 3. };
529 UNUR_GEN *clone;
530 distr = unur_distr_multinormal( dim, mean, covar );
531 par = unur_mvtdr_new(distr);
532 gen = unur_init( par );
533 abort_if_NULL(TESTLOG, 204, gen );
534
535
536 unur_reset_errno();
537 ;
538 n_tests_failed += (compare_sequence_gen_start(TESTLOG,207,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
539
540 unur_reset_errno();
541 /* clone */
542 clone = unur_gen_clone(gen);
543 unur_free(gen);
544 gen = clone;
545 n_tests_failed += (compare_sequence_gen(TESTLOG,213,gen,COMPARE_SAMPLE_SIZE)==UNUR_SUCCESS)?0:1;
546 unur_distr_free(distr);
547 unur_free(gen);
548 }
549
550
551 /* timing */
552 stopwatch_print(TESTLOG,"\n<*>time = %.3f ms\n\n", stopwatch_lap(&watch));
553
554 /* test finished */
555 test_ok &= (n_tests_failed) ? 0 : 1;
556 (n_tests_failed) ? printf(" ==> failed] ") : printf(" ==> ok] ");
557
558 } /* end of test_sample() */
559
560 /*---------------------------------------------------------------------------*/
561 /* [validate] */
562
563 /*---------------------------------------------------------------------------*/
564
565 /* [validate] */
566
test_validate(void)567 void test_validate (void)
568 {
569 UNUR_DISTR *distr[39];
570 UNUR_PAR *par;
571 UNUR_GEN *gen;
572 int n_tests_failed;
573 int rcode;
574 double *darray;
575 double fpm[10];
576
577 rcode = 0;
578
579 /* start test */
580 printf("[validate "); fflush(stdout);
581 fprintf(TESTLOG,"\n[validate]\n");
582
583 /* reset counter */
584 n_tests_failed = 0;
585
586 /* set stop watch */
587 stopwatch_lap(&watch);
588
589
590 /* distributions: 39 */
591 {
592 distr[0] = unur_distr_multinormal(2,NULL,NULL);
593 }
594
595 {
596 distr[1] = unur_distr_multinormal(3,NULL,NULL);
597 }
598
599 {
600 distr[2] = unur_distr_multinormal(4,NULL,NULL);
601 }
602
603 {
604 distr[3] = unur_distr_multinormal(5,NULL,NULL);
605 }
606
607 {
608 distr[4] = unur_distr_multinormal(6,NULL,NULL);
609 }
610
611 {
612 distr[5] = unur_distr_multinormal(7,NULL,NULL);
613 }
614
615 {
616 {double ll[2] = {-1.,-1.};
617 double ru[2] = { 1., 1.};
618 distr[6] = unur_distr_multinormal(2,NULL,NULL);
619 unur_distr_cvec_set_domain_rect(distr[6],ll,ru); }
620 }
621
622 {
623 {double ll[3] = {-.1,-.1,-.1};
624 double ru[3] = { 1., 1., 1.};
625 distr[7] = unur_distr_multinormal(3,NULL,NULL);
626 unur_distr_cvec_set_domain_rect(distr[7],ll,ru); }
627 }
628
629 {
630 {double ll[3] = {-.1,-.1,-.1};
631 double ru[3] = {UNUR_INFINITY,UNUR_INFINITY,UNUR_INFINITY};
632 distr[8] = unur_distr_multinormal(3,NULL,NULL);
633 unur_distr_cvec_set_domain_rect(distr[8],ll,ru); }
634 }
635
636 {
637 {double ll[3] = {-UNUR_INFINITY,-UNUR_INFINITY,-UNUR_INFINITY};
638 double ru[3] = {0.1,0.1,0.1};
639 distr[9] = unur_distr_multinormal(3,NULL,NULL);
640 unur_distr_cvec_set_domain_rect(distr[9],ll,ru); }
641 }
642
643 {
644 {double ll[6] = {-1.,-1.,-1.,-1.,-1.,-1.};
645 double ru[6] = { 1., 1., 1., 1., 1., 1.};
646 distr[10] = unur_distr_multinormal(6,NULL,NULL);
647 unur_distr_cvec_set_domain_rect(distr[10],ll,ru); }
648 }
649
650 {
651 {double mean[] = { 10., 20., 30.};
652 double covar[] = { 2., 2., 1., 2., 4., 3., 1., 3., 3. };
653 distr[11] = unur_distr_multinormal(3,mean,covar); }
654 }
655
656 {
657 distr[12] = unur_distr_multinormal_ar1(3,NULL,0.9);
658 }
659
660 {
661 distr[13] = unur_distr_multinormal_ar1(4,NULL,0.9);
662 }
663
664 {
665 distr[14] = unur_distr_multinormal_ar1(5,NULL,0.9);
666 }
667
668 {
669 distr[15] = unur_distr_multinormal_ar1(6,NULL,0.5);
670 }
671
672 {
673 distr[16] = unur_distr_multinormal_ar1(7,NULL,0.3);
674 }
675
676 {
677 {double mean[] = { -1., -2., -3., 4., 5., 6., 7., 8., 9., 10. };
678 distr[17] = unur_distr_multinormal_ar1(3,mean,0.9); }
679 }
680
681 {
682 {double mean[] = { -1., -2., -3., 4., 5., 6., 7., 8., 9., 10. };
683 distr[18] = unur_distr_multinormal_ar1(4,mean,0.9); }
684 }
685
686 {
687 {double mean[] = { -1., -2., -3., 4., 5., 6., 7., 8., 9., 10. };
688 distr[19] = unur_distr_multinormal_ar1(5,mean,0.9); }
689 }
690
691 {
692 distr[20] = unur_distr_multinormal_constantrho(3,NULL,0.99);
693 }
694
695 {
696 distr[21] = unur_distr_multinormal_constantrho(4,NULL,0.9);
697 }
698
699 {
700 distr[22] = unur_distr_multinormal_constantrho(5,NULL,0.5);
701 }
702
703 {
704 {double ll[3] = {-.1,-.1,-.1};
705 double ru[3] = { 1., 1., 1.};
706 distr[23] = unur_distr_multinormal_ar1(3,NULL,0.9);
707 unur_distr_cvec_set_domain_rect(distr[23],ll,ru); }
708 }
709
710 {
711 {double ll[3] = { 0., 0., 0.};
712 double ru[3] = { 1., 1., 1.};
713 distr[24] = unur_distr_multinormal_ar1(3,NULL,0.9);
714 unur_distr_cvec_set_domain_rect(distr[24],ll,ru); }
715 }
716
717 {
718 {double ll[3] = {-1.,-1.,-1.};
719 double ru[3] = { 0., 0., 0.};
720 distr[25] = unur_distr_multinormal_ar1(3,NULL,0.9);
721 unur_distr_cvec_set_domain_rect(distr[25],ll,ru); }
722 }
723
724 {
725 {double ll[3] = {-1., 0.,-1.};
726 double ru[3] = { 0., 1., 0.};
727 distr[26] = unur_distr_multinormal_ar1(3,NULL,0.9);
728 unur_distr_cvec_set_domain_rect(distr[26],ll,ru); }
729 }
730
731 {
732 {double ll[3] = { 0., 0., 0.};
733 double ru[3] = { UNUR_INFINITY, UNUR_INFINITY, UNUR_INFINITY};
734 distr[27] = unur_distr_multinormal_ar1(3,NULL,0.9);
735 unur_distr_cvec_set_domain_rect(distr[27],ll,ru); }
736 }
737
738 {
739 {double ll[3] = { -UNUR_INFINITY, -UNUR_INFINITY, -UNUR_INFINITY};
740 double ru[3] = { 0., 0., 0.};
741 distr[28] = unur_distr_multinormal_ar1(3,NULL,0.9);
742 unur_distr_cvec_set_domain_rect(distr[28],ll,ru); }
743 }
744
745 {
746 {double ll[3] = { -UNUR_INFINITY, -UNUR_INFINITY, -UNUR_INFINITY};
747 double ru[3] = { 0., 0., UNUR_INFINITY};
748 distr[29] = unur_distr_multinormal_ar1(3,NULL,0.9);
749 unur_distr_cvec_set_domain_rect(distr[29],ll,ru); }
750 }
751
752 {
753 {double ll[3] = {-1.,-1.,-1.};
754 double ru[3] = { UNUR_INFINITY, UNUR_INFINITY, UNUR_INFINITY};
755 distr[30] = unur_distr_multinormal_ar1(3,NULL,0.9);
756 unur_distr_cvec_set_domain_rect(distr[30],ll,ru); }
757 }
758
759 {
760 {double ll[3] = {-.1,-.1,-.1};
761 double ru[3] = { 1., 1., 1.};
762 distr[31] = unur_distr_multinormal(3,NULL,NULL);
763 unur_distr_cvec_set_domain_rect(distr[31],ll,ru); }
764 }
765
766 {
767 {double ll[3] = { 0., 0., 0.};
768 double ru[3] = { 1., 1., 1.};
769 distr[32] = unur_distr_multinormal(3,NULL,NULL);
770 unur_distr_cvec_set_domain_rect(distr[32],ll,ru); }
771 }
772
773 {
774 {double ll[3] = {-1.,-1.,-1.};
775 double ru[3] = { 0., 0., 0.};
776 distr[33] = unur_distr_multinormal(3,NULL,NULL);
777 unur_distr_cvec_set_domain_rect(distr[33],ll,ru); }
778 }
779
780 {
781 {double ll[3] = {-1., 0.,-1.};
782 double ru[3] = { 0., 1., 0.};
783 distr[34] = unur_distr_multinormal(3,NULL,NULL);
784 unur_distr_cvec_set_domain_rect(distr[34],ll,ru); }
785 }
786
787 {
788 {double ll[3] = { 0., 0., 0.};
789 double ru[3] = { UNUR_INFINITY, UNUR_INFINITY, UNUR_INFINITY};
790 distr[35] = unur_distr_multinormal(3,NULL,NULL);
791 unur_distr_cvec_set_domain_rect(distr[35],ll,ru); }
792 }
793
794 {
795 {double ll[3] = { -UNUR_INFINITY, -UNUR_INFINITY, -UNUR_INFINITY};
796 double ru[3] = { 0., 0., 0.};
797 distr[36] = unur_distr_multinormal(3,NULL,NULL);
798 unur_distr_cvec_set_domain_rect(distr[36],ll,ru); }
799 }
800
801 {
802 {double ll[3] = { -UNUR_INFINITY, -UNUR_INFINITY, -UNUR_INFINITY};
803 double ru[3] = { 0., 0., UNUR_INFINITY};
804 distr[37] = unur_distr_multinormal(3,NULL,NULL);
805 unur_distr_cvec_set_domain_rect(distr[37],ll,ru); }
806 }
807
808 {
809 {double ll[3] = {-1.,-1.,-1.};
810 double ru[3] = { UNUR_INFINITY, UNUR_INFINITY, UNUR_INFINITY};
811 distr[38] = unur_distr_multinormal(3,NULL,NULL);
812 unur_distr_cvec_set_domain_rect(distr[38],ll,ru); }
813 }
814
815 /* timing */
816 stopwatch_print(TESTLOG,"\n<*>setup time = %.3f ms\n", stopwatch_lap(&watch));
817
818 printf("\n(chi^2) "); fflush(stdout);
819
820 /* chi^2 tests: 39 */
821
822 unur_set_default_debug(~UNUR_DEBUG_SAMPLE);
823 fprintf( TESTLOG,"\nChi^2 Test:\n");
824
825 /* distribution [0] */
826
827 if(TRUE) {
828 unur_reset_errno();
829 do {
830 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[0]);
831 par = unur_mvtdr_new(distr_localcopy);
832 gen = unur_init(par);
833 rcode = run_validate_chi2(TESTLOG,0,gen,distr[0],'+');
834 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
835 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
836 unur_free(gen);
837 unur_distr_free(distr_localcopy);
838 } while (0);
839 }
840
841 /* distribution [1] */
842
843 if(TRUE) {
844 unur_reset_errno();
845 do {
846 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[1]);
847 par = unur_mvtdr_new(distr_localcopy);
848 gen = unur_init(par);
849 rcode = run_validate_chi2(TESTLOG,0,gen,distr[1],'+');
850 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
851 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
852 unur_free(gen);
853 unur_distr_free(distr_localcopy);
854 } while (0);
855 }
856
857 /* distribution [2] */
858
859 if(TRUE) {
860 unur_reset_errno();
861 do {
862 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[2]);
863 par = unur_mvtdr_new(distr_localcopy);
864 gen = unur_init(par);
865 rcode = run_validate_chi2(TESTLOG,0,gen,distr[2],'+');
866 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
867 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
868 unur_free(gen);
869 unur_distr_free(distr_localcopy);
870 } while (0);
871 }
872
873 /* distribution [3] */
874
875 if(TRUE) {
876 unur_reset_errno();
877 do {
878 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[3]);
879 par = unur_mvtdr_new(distr_localcopy);
880 gen = unur_init(par);
881 rcode = run_validate_chi2(TESTLOG,0,gen,distr[3],'+');
882 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
883 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
884 unur_free(gen);
885 unur_distr_free(distr_localcopy);
886 } while (0);
887 }
888
889 /* distribution [4] */
890
891 if(TRUE) {
892 unur_reset_errno();
893 do {
894 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[4]);
895 par = unur_mvtdr_new(distr_localcopy);
896 gen = unur_init(par);
897 rcode = run_validate_chi2(TESTLOG,0,gen,distr[4],'+');
898 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
899 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
900 unur_free(gen);
901 unur_distr_free(distr_localcopy);
902 } while (0);
903 }
904
905 /* distribution [5] */
906
907 if(TRUE) {
908 unur_reset_errno();
909 do {
910 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[5]);
911 par = unur_mvtdr_new(distr_localcopy);
912 gen = unur_init(par);
913 rcode = run_validate_chi2(TESTLOG,0,gen,distr[5],'+');
914 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
915 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
916 unur_free(gen);
917 unur_distr_free(distr_localcopy);
918 } while (0);
919 }
920
921 /* distribution [6] */
922
923 if(TRUE) {
924 unur_reset_errno();
925 do {
926 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[6]);
927 par = unur_mvtdr_new(distr_localcopy);
928 gen = unur_init(par);
929 rcode = run_validate_chi2(TESTLOG,0,gen,distr[6],'+');
930 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
931 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
932 unur_free(gen);
933 unur_distr_free(distr_localcopy);
934 } while (0);
935 }
936
937 /* distribution [7] */
938
939 if(TRUE) {
940 unur_reset_errno();
941 do {
942 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[7]);
943 par = unur_mvtdr_new(distr_localcopy);
944 gen = unur_init(par);
945 rcode = run_validate_chi2(TESTLOG,0,gen,distr[7],'+');
946 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
947 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
948 unur_free(gen);
949 unur_distr_free(distr_localcopy);
950 } while (0);
951 }
952
953 /* distribution [8] */
954
955 if(TRUE) {
956 unur_reset_errno();
957 do {
958 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[8]);
959 par = unur_mvtdr_new(distr_localcopy);
960 gen = unur_init(par);
961 rcode = run_validate_chi2(TESTLOG,0,gen,distr[8],'+');
962 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
963 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
964 unur_free(gen);
965 unur_distr_free(distr_localcopy);
966 } while (0);
967 }
968
969 /* distribution [9] */
970
971 if(TRUE) {
972 unur_reset_errno();
973 do {
974 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[9]);
975 par = unur_mvtdr_new(distr_localcopy);
976 gen = unur_init(par);
977 rcode = run_validate_chi2(TESTLOG,0,gen,distr[9],'+');
978 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
979 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
980 unur_free(gen);
981 unur_distr_free(distr_localcopy);
982 } while (0);
983 }
984
985 /* distribution [10] */
986
987 if(TRUE) {
988 unur_reset_errno();
989 do {
990 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[10]);
991 par = unur_mvtdr_new(distr_localcopy);
992 gen = unur_init(par);
993 rcode = run_validate_chi2(TESTLOG,0,gen,distr[10],'+');
994 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
995 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
996 unur_free(gen);
997 unur_distr_free(distr_localcopy);
998 } while (0);
999 }
1000
1001 /* distribution [11] */
1002
1003 if(TRUE) {
1004 unur_reset_errno();
1005 do {
1006 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[11]);
1007 par = unur_mvtdr_new(distr_localcopy);
1008 gen = unur_init(par);
1009 rcode = run_validate_chi2(TESTLOG,0,gen,distr[11],'+');
1010 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1011 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1012 unur_free(gen);
1013 unur_distr_free(distr_localcopy);
1014 } while (0);
1015 }
1016
1017 /* distribution [12] */
1018
1019 if(TRUE) {
1020 unur_reset_errno();
1021 do {
1022 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[12]);
1023 par = unur_mvtdr_new(distr_localcopy);
1024 gen = unur_init(par);
1025 rcode = run_validate_chi2(TESTLOG,0,gen,distr[12],'+');
1026 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1027 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1028 unur_free(gen);
1029 unur_distr_free(distr_localcopy);
1030 } while (0);
1031 }
1032
1033 /* distribution [13] */
1034
1035 if(TRUE) {
1036 unur_reset_errno();
1037 do {
1038 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[13]);
1039 par = unur_mvtdr_new(distr_localcopy);
1040 gen = unur_init(par);
1041 rcode = run_validate_chi2(TESTLOG,0,gen,distr[13],'+');
1042 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1043 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1044 unur_free(gen);
1045 unur_distr_free(distr_localcopy);
1046 } while (0);
1047 }
1048
1049 /* distribution [14] */
1050
1051 if(TRUE) {
1052 unur_reset_errno();
1053 do {
1054 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[14]);
1055 par = unur_mvtdr_new(distr_localcopy);
1056 gen = unur_init(par);
1057 rcode = run_validate_chi2(TESTLOG,0,gen,distr[14],'+');
1058 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1059 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1060 unur_free(gen);
1061 unur_distr_free(distr_localcopy);
1062 } while (0);
1063 }
1064
1065 /* distribution [15] */
1066
1067 if(TRUE) {
1068 unur_reset_errno();
1069 do {
1070 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[15]);
1071 par = unur_mvtdr_new(distr_localcopy);
1072 gen = unur_init(par);
1073 rcode = run_validate_chi2(TESTLOG,0,gen,distr[15],'+');
1074 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1075 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1076 unur_free(gen);
1077 unur_distr_free(distr_localcopy);
1078 } while (0);
1079 }
1080
1081 /* distribution [16] */
1082
1083 if(TRUE) {
1084 unur_reset_errno();
1085 do {
1086 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[16]);
1087 par = unur_mvtdr_new(distr_localcopy);
1088 gen = unur_init(par);
1089 rcode = run_validate_chi2(TESTLOG,0,gen,distr[16],'+');
1090 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1091 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1092 unur_free(gen);
1093 unur_distr_free(distr_localcopy);
1094 } while (0);
1095 }
1096
1097 /* distribution [17] */
1098
1099 if(TRUE) {
1100 unur_reset_errno();
1101 do {
1102 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[17]);
1103 par = unur_mvtdr_new(distr_localcopy);
1104 gen = unur_init(par);
1105 rcode = run_validate_chi2(TESTLOG,0,gen,distr[17],'+');
1106 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1107 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1108 unur_free(gen);
1109 unur_distr_free(distr_localcopy);
1110 } while (0);
1111 }
1112
1113 /* distribution [18] */
1114
1115 if(TRUE) {
1116 unur_reset_errno();
1117 do {
1118 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[18]);
1119 par = unur_mvtdr_new(distr_localcopy);
1120 gen = unur_init(par);
1121 rcode = run_validate_chi2(TESTLOG,0,gen,distr[18],'+');
1122 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1123 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1124 unur_free(gen);
1125 unur_distr_free(distr_localcopy);
1126 } while (0);
1127 }
1128
1129 /* distribution [19] */
1130
1131 if(TRUE) {
1132 unur_reset_errno();
1133 do {
1134 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[19]);
1135 par = unur_mvtdr_new(distr_localcopy);
1136 gen = unur_init(par);
1137 rcode = run_validate_chi2(TESTLOG,0,gen,distr[19],'+');
1138 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1139 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1140 unur_free(gen);
1141 unur_distr_free(distr_localcopy);
1142 } while (0);
1143 }
1144
1145 /* distribution [20] */
1146
1147 if(TRUE) {
1148 unur_reset_errno();
1149 do {
1150 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[20]);
1151 par = unur_mvtdr_new(distr_localcopy);
1152 gen = unur_init(par);
1153 rcode = run_validate_chi2(TESTLOG,0,gen,distr[20],'+');
1154 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1155 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1156 unur_free(gen);
1157 unur_distr_free(distr_localcopy);
1158 } while (0);
1159 }
1160
1161 /* distribution [21] */
1162
1163 if(TRUE) {
1164 unur_reset_errno();
1165 do {
1166 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[21]);
1167 par = unur_mvtdr_new(distr_localcopy);
1168 gen = unur_init(par);
1169 rcode = run_validate_chi2(TESTLOG,0,gen,distr[21],'+');
1170 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1171 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1172 unur_free(gen);
1173 unur_distr_free(distr_localcopy);
1174 } while (0);
1175 }
1176
1177 /* distribution [22] */
1178
1179 if(TRUE) {
1180 unur_reset_errno();
1181 do {
1182 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[22]);
1183 par = unur_mvtdr_new(distr_localcopy);
1184 gen = unur_init(par);
1185 rcode = run_validate_chi2(TESTLOG,0,gen,distr[22],'+');
1186 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1187 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1188 unur_free(gen);
1189 unur_distr_free(distr_localcopy);
1190 } while (0);
1191 }
1192
1193 /* distribution [31] */
1194
1195 if(TRUE) {
1196 unur_reset_errno();
1197 do {
1198 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[31]);
1199 par = unur_mvtdr_new(distr_localcopy);
1200 gen = unur_init(par);
1201 rcode = run_validate_chi2(TESTLOG,0,gen,distr[31],'+');
1202 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1203 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1204 unur_free(gen);
1205 unur_distr_free(distr_localcopy);
1206 } while (0);
1207 }
1208
1209 /* distribution [32] */
1210
1211 if(TRUE) {
1212 unur_reset_errno();
1213 do {
1214 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[32]);
1215 par = unur_mvtdr_new(distr_localcopy);
1216 gen = unur_init(par);
1217 rcode = run_validate_chi2(TESTLOG,0,gen,distr[32],'+');
1218 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1219 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1220 unur_free(gen);
1221 unur_distr_free(distr_localcopy);
1222 } while (0);
1223 }
1224
1225 /* distribution [33] */
1226
1227 if(TRUE) {
1228 unur_reset_errno();
1229 do {
1230 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[33]);
1231 par = unur_mvtdr_new(distr_localcopy);
1232 gen = unur_init(par);
1233 rcode = run_validate_chi2(TESTLOG,0,gen,distr[33],'+');
1234 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1235 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1236 unur_free(gen);
1237 unur_distr_free(distr_localcopy);
1238 } while (0);
1239 }
1240
1241 /* distribution [34] */
1242
1243 if(TRUE) {
1244 unur_reset_errno();
1245 do {
1246 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[34]);
1247 par = unur_mvtdr_new(distr_localcopy);
1248 gen = unur_init(par);
1249 rcode = run_validate_chi2(TESTLOG,0,gen,distr[34],'+');
1250 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1251 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1252 unur_free(gen);
1253 unur_distr_free(distr_localcopy);
1254 } while (0);
1255 }
1256
1257 /* distribution [35] */
1258
1259 if(TRUE) {
1260 unur_reset_errno();
1261 do {
1262 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[35]);
1263 par = unur_mvtdr_new(distr_localcopy);
1264 gen = unur_init(par);
1265 rcode = run_validate_chi2(TESTLOG,0,gen,distr[35],'+');
1266 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1267 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1268 unur_free(gen);
1269 unur_distr_free(distr_localcopy);
1270 } while (0);
1271 }
1272
1273 /* distribution [36] */
1274
1275 if(TRUE) {
1276 unur_reset_errno();
1277 do {
1278 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[36]);
1279 par = unur_mvtdr_new(distr_localcopy);
1280 gen = unur_init(par);
1281 rcode = run_validate_chi2(TESTLOG,0,gen,distr[36],'+');
1282 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1283 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1284 unur_free(gen);
1285 unur_distr_free(distr_localcopy);
1286 } while (0);
1287 }
1288
1289 /* distribution [37] */
1290
1291 if(TRUE) {
1292 unur_reset_errno();
1293 do {
1294 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[37]);
1295 par = unur_mvtdr_new(distr_localcopy);
1296 gen = unur_init(par);
1297 rcode = run_validate_chi2(TESTLOG,0,gen,distr[37],'+');
1298 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1299 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1300 unur_free(gen);
1301 unur_distr_free(distr_localcopy);
1302 } while (0);
1303 }
1304
1305 /* distribution [38] */
1306
1307 if(TRUE) {
1308 unur_reset_errno();
1309 do {
1310 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[38]);
1311 par = unur_mvtdr_new(distr_localcopy);
1312 gen = unur_init(par);
1313 rcode = run_validate_chi2(TESTLOG,0,gen,distr[38],'+');
1314 n_tests_failed += (rcode==UNUR_SUCCESS)?0:1;
1315 n_tests_failed += (rcode==UNUR_FAILURE)?1000:0;
1316 unur_free(gen);
1317 unur_distr_free(distr_localcopy);
1318 } while (0);
1319 }
1320
1321 /* timing */
1322 stopwatch_print(TESTLOG,"\n<*>time = %.0f ms\n", stopwatch_lap(&watch));
1323
1324 printf("\n(verify hat) "); fflush(stdout);
1325
1326 /* verify hat tests: 39 */
1327
1328 unur_set_default_debug(~UNUR_DEBUG_SAMPLE);
1329 fprintf( TESTLOG,"\nVerify Hat Test (squeeze <= PDF <= hat):\n");
1330
1331 /* distribution [0] */
1332
1333 if(TRUE) {
1334 unur_reset_errno();
1335 do {
1336 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[0]);
1337 par = unur_mvtdr_new(distr_localcopy);
1338 unur_mvtdr_set_pedantic(par,0);
1339 gen = unur_init(par);
1340 if (gen) unur_mvtdr_chg_verify(gen,1);
1341 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[0],'~')==UNUR_SUCCESS)?0:1000;
1342 unur_free(gen);
1343
1344 unur_distr_free(distr_localcopy);
1345 } while (0);
1346 }
1347
1348 /* distribution [1] */
1349
1350 if(TRUE) {
1351 unur_reset_errno();
1352 do {
1353 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[1]);
1354 par = unur_mvtdr_new(distr_localcopy);
1355 unur_mvtdr_set_pedantic(par,0);
1356 gen = unur_init(par);
1357 if (gen) unur_mvtdr_chg_verify(gen,1);
1358 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[1],'~')==UNUR_SUCCESS)?0:1000;
1359 unur_free(gen);
1360
1361 unur_distr_free(distr_localcopy);
1362 } while (0);
1363 }
1364
1365 /* distribution [2] */
1366
1367 if(TRUE) {
1368 unur_reset_errno();
1369 do {
1370 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[2]);
1371 par = unur_mvtdr_new(distr_localcopy);
1372 unur_mvtdr_set_pedantic(par,0);
1373 gen = unur_init(par);
1374 if (gen) unur_mvtdr_chg_verify(gen,1);
1375 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[2],'~')==UNUR_SUCCESS)?0:1000;
1376 unur_free(gen);
1377
1378 unur_distr_free(distr_localcopy);
1379 } while (0);
1380 }
1381
1382 /* distribution [3] */
1383
1384 if(TRUE) {
1385 unur_reset_errno();
1386 do {
1387 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[3]);
1388 par = unur_mvtdr_new(distr_localcopy);
1389 unur_mvtdr_set_pedantic(par,0);
1390 gen = unur_init(par);
1391 if (gen) unur_mvtdr_chg_verify(gen,1);
1392 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[3],'~')==UNUR_SUCCESS)?0:1000;
1393 unur_free(gen);
1394
1395 unur_distr_free(distr_localcopy);
1396 } while (0);
1397 }
1398
1399 /* distribution [4] */
1400
1401 if(TRUE) {
1402 unur_reset_errno();
1403 do {
1404 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[4]);
1405 par = unur_mvtdr_new(distr_localcopy);
1406 unur_mvtdr_set_pedantic(par,0);
1407 gen = unur_init(par);
1408 if (gen) unur_mvtdr_chg_verify(gen,1);
1409 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[4],'~')==UNUR_SUCCESS)?0:1000;
1410 unur_free(gen);
1411
1412 unur_distr_free(distr_localcopy);
1413 } while (0);
1414 }
1415
1416 /* distribution [5] */
1417
1418 if(TRUE) {
1419 unur_reset_errno();
1420 do {
1421 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[5]);
1422 par = unur_mvtdr_new(distr_localcopy);
1423 unur_mvtdr_set_pedantic(par,0);
1424 gen = unur_init(par);
1425 if (gen) unur_mvtdr_chg_verify(gen,1);
1426 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[5],'~')==UNUR_SUCCESS)?0:1000;
1427 unur_free(gen);
1428
1429 unur_distr_free(distr_localcopy);
1430 } while (0);
1431 }
1432
1433 /* distribution [6] */
1434
1435 if(TRUE) {
1436 unur_reset_errno();
1437 do {
1438 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[6]);
1439 par = unur_mvtdr_new(distr_localcopy);
1440 unur_mvtdr_set_pedantic(par,0);
1441 gen = unur_init(par);
1442 if (gen) unur_mvtdr_chg_verify(gen,1);
1443 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[6],'~')==UNUR_SUCCESS)?0:1000;
1444 unur_free(gen);
1445
1446 unur_distr_free(distr_localcopy);
1447 } while (0);
1448 }
1449
1450 /* distribution [7] */
1451
1452 if(TRUE) {
1453 unur_reset_errno();
1454 do {
1455 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[7]);
1456 par = unur_mvtdr_new(distr_localcopy);
1457 unur_mvtdr_set_pedantic(par,0);
1458 gen = unur_init(par);
1459 if (gen) unur_mvtdr_chg_verify(gen,1);
1460 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[7],'~')==UNUR_SUCCESS)?0:1000;
1461 unur_free(gen);
1462
1463 unur_distr_free(distr_localcopy);
1464 } while (0);
1465 }
1466
1467 /* distribution [8] */
1468
1469 if(TRUE) {
1470 unur_reset_errno();
1471 do {
1472 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[8]);
1473 par = unur_mvtdr_new(distr_localcopy);
1474 unur_mvtdr_set_pedantic(par,0);
1475 gen = unur_init(par);
1476 if (gen) unur_mvtdr_chg_verify(gen,1);
1477 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[8],'~')==UNUR_SUCCESS)?0:1000;
1478 unur_free(gen);
1479
1480 unur_distr_free(distr_localcopy);
1481 } while (0);
1482 }
1483
1484 /* distribution [9] */
1485
1486 if(TRUE) {
1487 unur_reset_errno();
1488 do {
1489 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[9]);
1490 par = unur_mvtdr_new(distr_localcopy);
1491 unur_mvtdr_set_pedantic(par,0);
1492 gen = unur_init(par);
1493 if (gen) unur_mvtdr_chg_verify(gen,1);
1494 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[9],'~')==UNUR_SUCCESS)?0:1000;
1495 unur_free(gen);
1496
1497 unur_distr_free(distr_localcopy);
1498 } while (0);
1499 }
1500
1501 /* distribution [10] */
1502
1503 if(TRUE) {
1504 unur_reset_errno();
1505 do {
1506 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[10]);
1507 par = unur_mvtdr_new(distr_localcopy);
1508 unur_mvtdr_set_pedantic(par,0);
1509 gen = unur_init(par);
1510 if (gen) unur_mvtdr_chg_verify(gen,1);
1511 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[10],'~')==UNUR_SUCCESS)?0:1000;
1512 unur_free(gen);
1513
1514 unur_distr_free(distr_localcopy);
1515 } while (0);
1516 }
1517
1518 /* distribution [11] */
1519
1520 if(TRUE) {
1521 unur_reset_errno();
1522 do {
1523 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[11]);
1524 par = unur_mvtdr_new(distr_localcopy);
1525 unur_mvtdr_set_pedantic(par,0);
1526 gen = unur_init(par);
1527 if (gen) unur_mvtdr_chg_verify(gen,1);
1528 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[11],'~')==UNUR_SUCCESS)?0:1000;
1529 unur_free(gen);
1530
1531 unur_distr_free(distr_localcopy);
1532 } while (0);
1533 }
1534
1535 /* distribution [12] */
1536
1537 if(TRUE) {
1538 unur_reset_errno();
1539 do {
1540 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[12]);
1541 par = unur_mvtdr_new(distr_localcopy);
1542 unur_mvtdr_set_pedantic(par,0);
1543 gen = unur_init(par);
1544 if (gen) unur_mvtdr_chg_verify(gen,1);
1545 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[12],'~')==UNUR_SUCCESS)?0:1000;
1546 unur_free(gen);
1547
1548 unur_distr_free(distr_localcopy);
1549 } while (0);
1550 }
1551
1552 /* distribution [13] */
1553
1554 if(TRUE) {
1555 unur_reset_errno();
1556 do {
1557 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[13]);
1558 par = unur_mvtdr_new(distr_localcopy);
1559 unur_mvtdr_set_pedantic(par,0);
1560 gen = unur_init(par);
1561 if (gen) unur_mvtdr_chg_verify(gen,1);
1562 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[13],'~')==UNUR_SUCCESS)?0:1000;
1563 unur_free(gen);
1564
1565 unur_distr_free(distr_localcopy);
1566 } while (0);
1567 }
1568
1569 /* distribution [14] */
1570
1571 if(TRUE) {
1572 unur_reset_errno();
1573 do {
1574 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[14]);
1575 par = unur_mvtdr_new(distr_localcopy);
1576 unur_mvtdr_set_pedantic(par,0);
1577 gen = unur_init(par);
1578 if (gen) unur_mvtdr_chg_verify(gen,1);
1579 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[14],'~')==UNUR_SUCCESS)?0:1000;
1580 unur_free(gen);
1581
1582 unur_distr_free(distr_localcopy);
1583 } while (0);
1584 }
1585
1586 /* distribution [15] */
1587
1588 if(TRUE) {
1589 unur_reset_errno();
1590 do {
1591 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[15]);
1592 par = unur_mvtdr_new(distr_localcopy);
1593 unur_mvtdr_set_pedantic(par,0);
1594 gen = unur_init(par);
1595 if (gen) unur_mvtdr_chg_verify(gen,1);
1596 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[15],'~')==UNUR_SUCCESS)?0:1000;
1597 unur_free(gen);
1598
1599 unur_distr_free(distr_localcopy);
1600 } while (0);
1601 }
1602
1603 /* distribution [16] */
1604
1605 if(TRUE) {
1606 unur_reset_errno();
1607 do {
1608 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[16]);
1609 par = unur_mvtdr_new(distr_localcopy);
1610 unur_mvtdr_set_pedantic(par,0);
1611 gen = unur_init(par);
1612 if (gen) unur_mvtdr_chg_verify(gen,1);
1613 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[16],'~')==UNUR_SUCCESS)?0:1000;
1614 unur_free(gen);
1615
1616 unur_distr_free(distr_localcopy);
1617 } while (0);
1618 }
1619
1620 /* distribution [17] */
1621
1622 if(TRUE) {
1623 unur_reset_errno();
1624 do {
1625 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[17]);
1626 par = unur_mvtdr_new(distr_localcopy);
1627 unur_mvtdr_set_pedantic(par,0);
1628 gen = unur_init(par);
1629 if (gen) unur_mvtdr_chg_verify(gen,1);
1630 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[17],'~')==UNUR_SUCCESS)?0:1000;
1631 unur_free(gen);
1632
1633 unur_distr_free(distr_localcopy);
1634 } while (0);
1635 }
1636
1637 /* distribution [18] */
1638
1639 if(TRUE) {
1640 unur_reset_errno();
1641 do {
1642 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[18]);
1643 par = unur_mvtdr_new(distr_localcopy);
1644 unur_mvtdr_set_pedantic(par,0);
1645 gen = unur_init(par);
1646 if (gen) unur_mvtdr_chg_verify(gen,1);
1647 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[18],'~')==UNUR_SUCCESS)?0:1000;
1648 unur_free(gen);
1649
1650 unur_distr_free(distr_localcopy);
1651 } while (0);
1652 }
1653
1654 /* distribution [19] */
1655
1656 if(TRUE) {
1657 unur_reset_errno();
1658 do {
1659 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[19]);
1660 par = unur_mvtdr_new(distr_localcopy);
1661 unur_mvtdr_set_pedantic(par,0);
1662 gen = unur_init(par);
1663 if (gen) unur_mvtdr_chg_verify(gen,1);
1664 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[19],'~')==UNUR_SUCCESS)?0:1000;
1665 unur_free(gen);
1666
1667 unur_distr_free(distr_localcopy);
1668 } while (0);
1669 }
1670
1671 /* distribution [20] */
1672
1673 if(TRUE) {
1674 unur_reset_errno();
1675 do {
1676 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[20]);
1677 par = unur_mvtdr_new(distr_localcopy);
1678 unur_mvtdr_set_pedantic(par,0);
1679 gen = unur_init(par);
1680 if (gen) unur_mvtdr_chg_verify(gen,1);
1681 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[20],'~')==UNUR_SUCCESS)?0:1000;
1682 unur_free(gen);
1683
1684 unur_distr_free(distr_localcopy);
1685 } while (0);
1686 }
1687
1688 /* distribution [21] */
1689
1690 if(TRUE) {
1691 unur_reset_errno();
1692 do {
1693 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[21]);
1694 par = unur_mvtdr_new(distr_localcopy);
1695 unur_mvtdr_set_pedantic(par,0);
1696 gen = unur_init(par);
1697 if (gen) unur_mvtdr_chg_verify(gen,1);
1698 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[21],'~')==UNUR_SUCCESS)?0:1000;
1699 unur_free(gen);
1700
1701 unur_distr_free(distr_localcopy);
1702 } while (0);
1703 }
1704
1705 /* distribution [22] */
1706
1707 if(TRUE) {
1708 unur_reset_errno();
1709 do {
1710 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[22]);
1711 par = unur_mvtdr_new(distr_localcopy);
1712 unur_mvtdr_set_pedantic(par,0);
1713 gen = unur_init(par);
1714 if (gen) unur_mvtdr_chg_verify(gen,1);
1715 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[22],'~')==UNUR_SUCCESS)?0:1000;
1716 unur_free(gen);
1717
1718 unur_distr_free(distr_localcopy);
1719 } while (0);
1720 }
1721
1722 /* distribution [23] */
1723
1724 if(TRUE) {
1725 unur_reset_errno();
1726 do {
1727 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[23]);
1728 par = unur_mvtdr_new(distr_localcopy);
1729 unur_mvtdr_set_pedantic(par,0);
1730 gen = unur_init(par);
1731 if (gen) unur_mvtdr_chg_verify(gen,1);
1732 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[23],'~')==UNUR_SUCCESS)?0:1000;
1733 unur_free(gen);
1734
1735 unur_distr_free(distr_localcopy);
1736 } while (0);
1737 }
1738
1739 /* distribution [24] */
1740
1741 if(TRUE) {
1742 unur_reset_errno();
1743 do {
1744 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[24]);
1745 par = unur_mvtdr_new(distr_localcopy);
1746 unur_mvtdr_set_pedantic(par,0);
1747 gen = unur_init(par);
1748 if (gen) unur_mvtdr_chg_verify(gen,1);
1749 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[24],'~')==UNUR_SUCCESS)?0:1000;
1750 unur_free(gen);
1751
1752 unur_distr_free(distr_localcopy);
1753 } while (0);
1754 }
1755
1756 /* distribution [25] */
1757
1758 if(TRUE) {
1759 unur_reset_errno();
1760 do {
1761 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[25]);
1762 par = unur_mvtdr_new(distr_localcopy);
1763 unur_mvtdr_set_pedantic(par,0);
1764 gen = unur_init(par);
1765 if (gen) unur_mvtdr_chg_verify(gen,1);
1766 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[25],'~')==UNUR_SUCCESS)?0:1000;
1767 unur_free(gen);
1768
1769 unur_distr_free(distr_localcopy);
1770 } while (0);
1771 }
1772
1773 /* distribution [26] */
1774
1775 if(TRUE) {
1776 unur_reset_errno();
1777 do {
1778 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[26]);
1779 par = unur_mvtdr_new(distr_localcopy);
1780 unur_mvtdr_set_pedantic(par,0);
1781 gen = unur_init(par);
1782 if (gen) unur_mvtdr_chg_verify(gen,1);
1783 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[26],'~')==UNUR_SUCCESS)?0:1000;
1784 unur_free(gen);
1785
1786 unur_distr_free(distr_localcopy);
1787 } while (0);
1788 }
1789
1790 /* distribution [27] */
1791
1792 if(TRUE) {
1793 unur_reset_errno();
1794 do {
1795 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[27]);
1796 par = unur_mvtdr_new(distr_localcopy);
1797 unur_mvtdr_set_pedantic(par,0);
1798 gen = unur_init(par);
1799 if (gen) unur_mvtdr_chg_verify(gen,1);
1800 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[27],'~')==UNUR_SUCCESS)?0:1000;
1801 unur_free(gen);
1802
1803 unur_distr_free(distr_localcopy);
1804 } while (0);
1805 }
1806
1807 /* distribution [28] */
1808
1809 if(TRUE) {
1810 unur_reset_errno();
1811 do {
1812 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[28]);
1813 par = unur_mvtdr_new(distr_localcopy);
1814 unur_mvtdr_set_pedantic(par,0);
1815 gen = unur_init(par);
1816 if (gen) unur_mvtdr_chg_verify(gen,1);
1817 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[28],'~')==UNUR_SUCCESS)?0:1000;
1818 unur_free(gen);
1819
1820 unur_distr_free(distr_localcopy);
1821 } while (0);
1822 }
1823
1824 /* distribution [29] */
1825
1826 if(TRUE) {
1827 unur_reset_errno();
1828 do {
1829 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[29]);
1830 par = unur_mvtdr_new(distr_localcopy);
1831 unur_mvtdr_set_pedantic(par,0);
1832 gen = unur_init(par);
1833 if (gen) unur_mvtdr_chg_verify(gen,1);
1834 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[29],'~')==UNUR_SUCCESS)?0:1000;
1835 unur_free(gen);
1836
1837 unur_distr_free(distr_localcopy);
1838 } while (0);
1839 }
1840
1841 /* distribution [30] */
1842
1843 if(TRUE) {
1844 unur_reset_errno();
1845 do {
1846 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[30]);
1847 par = unur_mvtdr_new(distr_localcopy);
1848 unur_mvtdr_set_pedantic(par,0);
1849 gen = unur_init(par);
1850 if (gen) unur_mvtdr_chg_verify(gen,1);
1851 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[30],'~')==UNUR_SUCCESS)?0:1000;
1852 unur_free(gen);
1853
1854 unur_distr_free(distr_localcopy);
1855 } while (0);
1856 }
1857
1858 /* distribution [31] */
1859
1860 if(TRUE) {
1861 unur_reset_errno();
1862 do {
1863 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[31]);
1864 par = unur_mvtdr_new(distr_localcopy);
1865 unur_mvtdr_set_pedantic(par,0);
1866 gen = unur_init(par);
1867 if (gen) unur_mvtdr_chg_verify(gen,1);
1868 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[31],'~')==UNUR_SUCCESS)?0:1000;
1869 unur_free(gen);
1870
1871 unur_distr_free(distr_localcopy);
1872 } while (0);
1873 }
1874
1875 /* distribution [32] */
1876
1877 if(TRUE) {
1878 unur_reset_errno();
1879 do {
1880 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[32]);
1881 par = unur_mvtdr_new(distr_localcopy);
1882 unur_mvtdr_set_pedantic(par,0);
1883 gen = unur_init(par);
1884 if (gen) unur_mvtdr_chg_verify(gen,1);
1885 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[32],'~')==UNUR_SUCCESS)?0:1000;
1886 unur_free(gen);
1887
1888 unur_distr_free(distr_localcopy);
1889 } while (0);
1890 }
1891
1892 /* distribution [33] */
1893
1894 if(TRUE) {
1895 unur_reset_errno();
1896 do {
1897 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[33]);
1898 par = unur_mvtdr_new(distr_localcopy);
1899 unur_mvtdr_set_pedantic(par,0);
1900 gen = unur_init(par);
1901 if (gen) unur_mvtdr_chg_verify(gen,1);
1902 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[33],'~')==UNUR_SUCCESS)?0:1000;
1903 unur_free(gen);
1904
1905 unur_distr_free(distr_localcopy);
1906 } while (0);
1907 }
1908
1909 /* distribution [34] */
1910
1911 if(TRUE) {
1912 unur_reset_errno();
1913 do {
1914 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[34]);
1915 par = unur_mvtdr_new(distr_localcopy);
1916 unur_mvtdr_set_pedantic(par,0);
1917 gen = unur_init(par);
1918 if (gen) unur_mvtdr_chg_verify(gen,1);
1919 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[34],'~')==UNUR_SUCCESS)?0:1000;
1920 unur_free(gen);
1921
1922 unur_distr_free(distr_localcopy);
1923 } while (0);
1924 }
1925
1926 /* distribution [35] */
1927
1928 if(TRUE) {
1929 unur_reset_errno();
1930 do {
1931 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[35]);
1932 par = unur_mvtdr_new(distr_localcopy);
1933 unur_mvtdr_set_pedantic(par,0);
1934 gen = unur_init(par);
1935 if (gen) unur_mvtdr_chg_verify(gen,1);
1936 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[35],'~')==UNUR_SUCCESS)?0:1000;
1937 unur_free(gen);
1938
1939 unur_distr_free(distr_localcopy);
1940 } while (0);
1941 }
1942
1943 /* distribution [36] */
1944
1945 if(TRUE) {
1946 unur_reset_errno();
1947 do {
1948 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[36]);
1949 par = unur_mvtdr_new(distr_localcopy);
1950 unur_mvtdr_set_pedantic(par,0);
1951 gen = unur_init(par);
1952 if (gen) unur_mvtdr_chg_verify(gen,1);
1953 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[36],'~')==UNUR_SUCCESS)?0:1000;
1954 unur_free(gen);
1955
1956 unur_distr_free(distr_localcopy);
1957 } while (0);
1958 }
1959
1960 /* distribution [37] */
1961
1962 if(TRUE) {
1963 unur_reset_errno();
1964 do {
1965 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[37]);
1966 par = unur_mvtdr_new(distr_localcopy);
1967 unur_mvtdr_set_pedantic(par,0);
1968 gen = unur_init(par);
1969 if (gen) unur_mvtdr_chg_verify(gen,1);
1970 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[37],'~')==UNUR_SUCCESS)?0:1000;
1971 unur_free(gen);
1972
1973 unur_distr_free(distr_localcopy);
1974 } while (0);
1975 }
1976
1977 /* distribution [38] */
1978
1979 if(TRUE) {
1980 unur_reset_errno();
1981 do {
1982 UNUR_DISTR *distr_localcopy = unur_distr_clone(distr[38]);
1983 par = unur_mvtdr_new(distr_localcopy);
1984 unur_mvtdr_set_pedantic(par,0);
1985 gen = unur_init(par);
1986 if (gen) unur_mvtdr_chg_verify(gen,1);
1987 n_tests_failed += (run_validate_verifyhat(TESTLOG,0,gen,distr[38],'~')==UNUR_SUCCESS)?0:1000;
1988 unur_free(gen);
1989
1990 unur_distr_free(distr_localcopy);
1991 } while (0);
1992 }
1993
1994 /* timing */
1995 stopwatch_print(TESTLOG,"\n<*>time = %.0f ms\n", stopwatch_lap(&watch));
1996
1997
1998 /* free distributions */
1999 unur_distr_free(distr[0]);
2000 unur_distr_free(distr[1]);
2001 unur_distr_free(distr[2]);
2002 unur_distr_free(distr[3]);
2003 unur_distr_free(distr[4]);
2004 unur_distr_free(distr[5]);
2005 unur_distr_free(distr[6]);
2006 unur_distr_free(distr[7]);
2007 unur_distr_free(distr[8]);
2008 unur_distr_free(distr[9]);
2009 unur_distr_free(distr[10]);
2010 unur_distr_free(distr[11]);
2011 unur_distr_free(distr[12]);
2012 unur_distr_free(distr[13]);
2013 unur_distr_free(distr[14]);
2014 unur_distr_free(distr[15]);
2015 unur_distr_free(distr[16]);
2016 unur_distr_free(distr[17]);
2017 unur_distr_free(distr[18]);
2018 unur_distr_free(distr[19]);
2019 unur_distr_free(distr[20]);
2020 unur_distr_free(distr[21]);
2021 unur_distr_free(distr[22]);
2022 unur_distr_free(distr[23]);
2023 unur_distr_free(distr[24]);
2024 unur_distr_free(distr[25]);
2025 unur_distr_free(distr[26]);
2026 unur_distr_free(distr[27]);
2027 unur_distr_free(distr[28]);
2028 unur_distr_free(distr[29]);
2029 unur_distr_free(distr[30]);
2030 unur_distr_free(distr[31]);
2031 unur_distr_free(distr[32]);
2032 unur_distr_free(distr[33]);
2033 unur_distr_free(distr[34]);
2034 unur_distr_free(distr[35]);
2035 unur_distr_free(distr[36]);
2036 unur_distr_free(distr[37]);
2037 unur_distr_free(distr[38]);
2038
2039 /* test finished */
2040 test_ok &= (n_tests_failed>CHI2_FAILURES_TOLERATED) ? 0 : 1;
2041 /* we accept CHI2_FAILURES_TOLERATED failures */
2042 (n_tests_failed>CHI2_FAILURES_TOLERATED) ? printf(" ==> failed] ") : printf(" ==> ok] ");
2043
2044 /* prevent compiler from making useless annoying warnings */
2045 distr[0] = NULL;
2046 par = NULL;
2047 gen = NULL;
2048 darray = NULL;
2049 fpm[0] = 0.;
2050
2051 } /* end of test_validate */
2052
2053
2054 /*---------------------------------------------------------------------------*/
2055 /* run generator in verifying mode */
2056
run_verify_generator(FILE * LOG,int line,UNUR_PAR * par)2057 void run_verify_generator( FILE *LOG, int line, UNUR_PAR *par )
2058 {
2059 UNUR_GEN *gen;
2060 int i;
2061
2062 /* switch to verifying mode */
2063 unur_mvtdr_set_verify(par,1);
2064
2065 /* initialize generator */
2066 gen = unur_init( par ); abort_if_NULL(LOG, line, gen);
2067
2068 /* run generator */
2069 for (i=0; i<VIOLATE_SAMPLE_SIZE; i++)
2070 unur_sample_cont(gen);
2071
2072 /* destroy generator */
2073 unur_free(gen);
2074
2075 } /* end of run_verify_generator() */
2076
2077
2078 /*---------------------------------------------------------------------------*/
2079
main(void)2080 int main(void)
2081 {
2082 unsigned long seed;
2083 char *str_seed, *str_tail;
2084
2085 /* start stop watch */
2086 stopwatch_init();
2087 stopwatch_start(&watch);
2088
2089 /* open log file for unuran and set output stream for unuran messages */
2090 UNURANLOG = fopen( "t_mvtdr_unuran.log","w" );
2091 abort_if_NULL( stderr,-1, UNURANLOG );
2092 unur_set_stream( UNURANLOG );
2093
2094 /* open log file for testing */
2095 TESTLOG = fopen( "t_mvtdr_test.log","w" );
2096 abort_if_NULL( stderr,-1, TESTLOG );
2097
2098 /* seed for uniform generators */
2099
2100 /* seed set by environment */
2101 str_seed = getenv("SEED");
2102
2103 if (str_seed != NULL) {
2104 seed = strtol(str_seed, &str_tail, 10);
2105 if (seed == 0u)
2106 seed = 873638;
2107 }
2108 else {
2109 #ifdef SEED
2110 seed = SEED;
2111 #else
2112 seed = 873638;
2113 #endif
2114 }
2115
2116 /* seed build-in uniform generators */
2117 unur_urng_MRG31k3p_seed(NULL,seed);
2118 unur_urng_fish_seed(NULL,seed);
2119 unur_urng_mstd_seed(NULL,seed);
2120
2121 /* seed uniform random number generator */
2122 #ifdef UNUR_URNG_UNURAN
2123 # ifdef UNUR_URNG_DEFAULT_RNGSTREAM
2124 {
2125 unsigned long sa[6];
2126 int i;
2127 for (i=0; i<6; i++) sa[i] = seed;
2128 RngStream_SetPackageSeed(sa);
2129 }
2130 # else
2131 if (unur_urng_seed(NULL,seed) != UNUR_SUCCESS) {
2132 fprintf(stderr,"WARNING: Seed could not be set at random\n");
2133 seed = ~0u;
2134 }
2135 # endif /* UNUR_URNG_DEFAULT_RNGSTREAM */
2136 #endif /* UNUR_URNG_UNURAN */
2137
2138 /* set default debugging flag */
2139 unur_set_default_debug(UNUR_DEBUG_ALL);
2140
2141 /* detect required check mode */
2142 fullcheck = (getenv("UNURANFULLCHECK")==NULL) ? FALSE : TRUE;
2143
2144 /* write header into log file */
2145 print_test_log_header( TESTLOG, seed, fullcheck );
2146
2147 /* set timer for sending SIGALRM signal */
2148 set_alarm(TESTLOG);
2149
2150 /* start test */
2151 printf("mvtdr: ");
2152
2153 /* run tests */
2154 test_new();
2155 test_set();
2156 test_get();
2157 test_chg();
2158 test_reinit();
2159 test_sample();
2160 test_validate();
2161
2162
2163 /* test finished */
2164 printf("\n"); fflush(stdout);
2165
2166 /* close log files */
2167 fprintf(TESTLOG,"\n====================================================\n\n");
2168 if (test_ok)
2169 fprintf(TESTLOG,"All tests PASSED.\n");
2170 else
2171 fprintf(TESTLOG,"Test(s) FAILED.\n");
2172
2173 /* timing */
2174 stopwatch_print(TESTLOG,"\n<*>total time = %.0f ms\n\n", stopwatch_stop(&watch));
2175
2176 fclose(UNURANLOG);
2177 fclose(TESTLOG);
2178
2179 /* free memory */
2180 compare_free_memory();
2181 unur_urng_free(unur_get_default_urng());
2182 unur_urng_free(unur_get_default_urng_aux());
2183
2184 /* exit */
2185 exit( (test_ok) ? EXIT_SUCCESS : EXIT_FAILURE );
2186
2187 } /* end of main */
2188
2189