1# $Id: t_deprecated_vmt.conf 5330 2011-04-19 10:50:18Z leydold $ 2############################################################################# 3# # 4# THIS METHOD AND THE CORRESPONDING ROUTINES SHOULD NOT BE USED ANY MORE! # 5# # 6############################################################################# 7 8[main] 9 10[main - data:] 11 12# method (for information only: the program scans the file name) 13method: VMT 14 15[main - header:] 16 17/* prototypes */ 18 19\#define COMPARE_SAMPLE_SIZE (10000) 20\#define VIOLATE_SAMPLE_SIZE (20) 21 22/* \#define SEED (298346) */ 23 24/* we need marginal distributions for the chi2 tests */ 25\#define unur_distr_multicauchy unur_distr_multicauchy_w_marginals 26\#define unur_distr_multinormal unur_distr_multinormal_w_marginals 27\#define unur_distr_multistudent unur_distr_multistudent_w_marginals 28 29 30############################################################################# 31 32[new] 33 34[new - invalid NULL ptr: 35 distr = NULL; ] 36 37~( distr ); 38 --> expected_NULL --> UNUR_ERR_NULL 39 40 41[new - invalid distribution type: 42 distr = unur_distr_discr_new(); ] 43 44~( distr ); 45 --> expected_NULL --> UNUR_ERR_DISTR_INVALID 46 47 48[new - data missing in distribution object: 49 double mean[] = {1.,2.}; 50 double covar[] = {2.,1., 1., 2.}; 51 distr = unur_distr_cvec_new(2); ] 52 53/* mean */ 54~( distr ); 55 --> expected_NULL --> UNUR_ERR_DISTR_REQUIRED 56 57/* covariance matrix */ 58unur_distr_cvec_set_mean(distr,mean); 59unur_distr_cvec_set_covar(distr,covar); 60~( distr ); 61 --> expected_NULL --> UNUR_ERR_DISTR_REQUIRED 62 63 64############################################################################# 65 66# [set] 67 68############################################################################# 69 70# [get] 71 72############################################################################# 73 74# [chg] 75 76############################################################################# 77 78# [init] 79 80############################################################################# 81 82[reinit] 83 84[reinit - exists: 85 distr = unur_distr_multinormal(3,NULL,NULL); 86 par = unur_vmt_new(distr); 87 gen = unur_init( par ); <-- ! NULL ] 88 89unur_reinit( gen ); 90 --> expected_reinit 91 92############################################################################# 93 94[sample] 95 96[sample - compare clone: 97 const int dim = 3; 98 double mean[] = {1.,2.,3.}; 99 double covar[] = { 2., 2., 1., 2., 4., 3., 1., 3., 3. }; 100 UNUR_GEN *clone; 101 distr = unur_distr_multinormal( dim, mean, covar ); 102 par = unur_vmt_new(distr); 103 gen = unur_init( par ); <-- ! NULL ] 104 105/* normal distribution */ 106 -->compare_sequence_gen_start 107 108/* clone */ 109clone = unur_gen_clone(gen); 110unur_free(gen); 111gen = clone; 112 -->compare_sequence_gen 113 114#..................................................................... 115 116[sample - compare clone: 117 const int dim = 3; 118 double mean[] = {1.,2.,3.}; 119 double covar[] = { 2., 2., 1., 2., 4., 3., 1., 3., 3. }; 120 double beta_params[] = {3.,5.}; 121 UNUR_GEN *clone; 122 distr = unur_distr_cvec_new(dim); 123 unur_distr_cvec_set_mean(distr,mean); 124 unur_distr_cvec_set_covar(distr,covar); 125 unur_distr_cvec_set_marginal_list(distr, 126 unur_distr_normal(NULL,0), 127 unur_distr_cauchy(NULL,0), 128 unur_distr_beta(beta_params,2) ); 129 unur_distr_cvec_set_stdmarginal_list(distr, 130 unur_distr_normal(NULL,0), 131 unur_distr_cauchy(NULL,0), 132 unur_distr_beta(beta_params,2) ); 133 par = unur_vmt_new(distr); 134 gen = unur_init( par ); <-- ! NULL ] 135 136/* multivariate distribution with given marginals */ 137 -->compare_sequence_gen_start 138 139/* clone */ 140clone = unur_gen_clone(gen); 141unur_free(gen); 142gen = clone; 143 -->compare_sequence_gen 144 145#..................................................................... 146 147[sample - compare clone: 148 double mean[] = {1.,2.,3.}; 149 double covar[] = { 2., 2., 1., 2., 4., 3., 1., 3., 3. }; 150 double beta_params[] = {3.,5.}; 151 UNUR_DISTR *marginals[3]; 152 UNUR_GEN *clone; 153 distr = unur_distr_cvec_new(3); 154 unur_distr_cvec_set_mean(distr,mean); 155 unur_distr_cvec_set_covar(distr,covar); 156 marginals[0] = unur_distr_normal(NULL,0); 157 marginals[1] = unur_distr_cauchy(NULL,0); 158 marginals[2] = unur_distr_beta(beta_params,2); 159 unur_distr_cvec_set_marginal_array(distr,marginals); 160 unur_distr_cvec_set_stdmarginal_array(distr,marginals); 161 unur_distr_free(marginals[0]); 162 unur_distr_free(marginals[1]); 163 unur_distr_free(marginals[2]); 164 par = unur_vmt_new(distr); 165 gen = unur_init( par ); <-- ! NULL ] 166 167/* multivariate distribution with given marginals */ 168 -->compare_sequence_gen_start 169 170/* clone */ 171clone = unur_gen_clone(gen); 172unur_free(gen); 173gen = clone; 174 -->compare_sequence_gen 175 176#..................................................................... 177 178[sample - compare clone 1dim: 179 const int dim = 1; 180 double mean[] = {1.}; 181 double covar[] = {2.}; 182 double beta_params[] = {3.,5.}; 183 UNUR_GEN *clone; 184 distr = unur_distr_cvec_new(dim); 185 unur_distr_cvec_set_mean(distr,mean); 186 unur_distr_cvec_set_covar(distr,covar); 187 unur_distr_cvec_set_marginal_list(distr, 188 unur_distr_beta(beta_params,2) ); 189 unur_distr_cvec_set_stdmarginal_list(distr, 190 unur_distr_beta(beta_params,2) ); 191 par = unur_vmt_new(distr); 192 gen = unur_init( par ); <-- ! NULL ] 193 194/* multivariate distribution with given marginals */ 195 -->compare_sequence_gen_start 196 197/* clone */ 198clone = unur_gen_clone(gen); 199unur_free(gen); 200gen = clone; 201 -->compare_sequence_gen 202 203#..................................................................... 204 205[sample - compare clone 1dim: 206 double mean[] = {1.}; 207 double covar[] = {2.}; 208 double beta_params[] = {3.,5.}; 209 UNUR_DISTR *marginals[1]; 210 UNUR_GEN *clone; 211 distr = unur_distr_cvec_new(1); 212 unur_distr_cvec_set_mean(distr,mean); 213 unur_distr_cvec_set_covar(distr,covar); 214 marginals[0] = unur_distr_beta(beta_params,2); 215 unur_distr_cvec_set_marginal_array(distr,marginals); 216 unur_distr_cvec_set_stdmarginal_array(distr,marginals); 217 unur_distr_free(marginals[0]); 218 par = unur_vmt_new(distr); 219 gen = unur_init( par ); <-- ! NULL ] 220 221/* multivariate distribution with given marginals */ 222 -->compare_sequence_gen_start 223 224/* clone */ 225clone = unur_gen_clone(gen); 226unur_free(gen); 227gen = clone; 228 -->compare_sequence_gen 229 230#..................................................................... 231 232[sample - compare reinit: 233 distr = unur_distr_multinormal(3,NULL,NULL); 234 par = NULL; 235 gen = NULL; ] 236 237/* original generator object */ 238par = unur_vmt_new(distr); 239gen = unur_init(par); 240 -->compare_sequence_gen_start 241 242/* reinit */ 243unur_reinit(gen); 244 -->compare_sequence_gen 245 246#..................................................................... 247 248[sample - set domain and compare clone: 249 const int dim = 3; 250 double mean[] = {1.,2.,3.}; 251 double covar[] = { 2., 2., 1., 2., 4., 3., 1., 3., 3. }; 252 double ll[] = {0.,0.,0.}; 253 double ru[] = {UNUR_INFINITY, 1., 2.}; 254 UNUR_GEN *clone; 255 distr = unur_distr_multinormal( dim, mean, covar ); 256 unur_distr_cvec_set_domain_rect( distr, ll, ru ); 257 par = unur_vmt_new(distr); 258 gen = unur_init( par ); <-- ! NULL ] 259 260/* normal distribution */ 261 -->compare_sequence_gen_start 262 263/* clone */ 264clone = unur_gen_clone(gen); 265unur_free(gen); 266gen = clone; 267 -->compare_sequence_gen 268 269 270############################################################################# 271 272[validate] 273 274[validate - generators:] 275 276# default program 277par[0] = unur_vmt_new(@distr@); 278 279# default variant but reinitialized with changed distribution 280{ UNUR_DISTR *dg =NULL; 281double mean[] = { -1., 2., -3. }; 282double covar[] = { 2., 2., 0.9, 2., 4., 3., 0.9, 3., 3. }; 283par[1] = unur_vmt_new(@distr@); 284dg = unur_get_distr(gen); 285unur_distr_cvec_set_mean(dg,mean); 286unur_distr_cvec_set_covar(dg,covar); 287unur_reinit(gen); } 288 289 290[validate - distributions:] 291 292# standard multinormal distribution 293distr[0] = unur_distr_multinormal(3,NULL,NULL); 294 295 296# multinormal distribution, dim = 3 297double mean[] = { 1., 2., 3. }; 298double covar[] = { 2., 2., 1., 2., 4., 3., 1., 3., 3. }; 299distr[1] = unur_distr_multinormal(3,mean,covar); 300 301# standard multinormal distribution with rectangular domain 302double ll[3] = {0.,0.,0.}; 303double ru[3] = {UNUR_INFINITY,UNUR_INFINITY,UNUR_INFINITY}; 304distr[30] = unur_distr_multinormal(3,NULL,NULL); 305unur_distr_cvec_set_domain_rect(distr[30],ll,ru); 306 307 308# standard multinormal distribution with rectangular domain 309double ll[3] = {0.,0.,0.}; 310double ru[3] = {1.,UNUR_INFINITY,UNUR_INFINITY}; 311distr[31] = unur_distr_multinormal(3,NULL,NULL); 312unur_distr_cvec_set_domain_rect(distr[31],ll,ru); 313 314# standard multinormal distribution with rectangular domain 315double ll[3] = {-1.,-1.,1.}; 316double ru[3] = {1.,0.,2.}; 317distr[32] = unur_distr_multinormal(3,NULL,NULL); 318unur_distr_cvec_set_domain_rect(distr[32],ll,ru); 319 320 321# random multinormal distribution 322\#define dim (2) 323int i; 324double mean[dim], covar[dim*dim]; 325UNUR_DISTR *covar_distr; 326UNUR_GEN *covar_gen; 327UNUR_GEN *mean_gen; 328covar_distr = unur_distr_correlation(dim); 329covar_gen = unur_init(unur_mcorr_new(covar_distr)); 330mean_gen = unur_str2gen("normal(5,1)"); 331for (i=0; i<dim; i++) 332 mean[i] = unur_sample_cont(mean_gen); 333do { 334 unur_sample_matr(covar_gen,covar); 335 distr[2] = unur_distr_multinormal(dim,mean,covar); 336} while (distr[2]==NULL); 337unur_distr_free(covar_distr); 338unur_free(covar_gen); 339unur_free(mean_gen); 340\#undef dim 341 342 343# random multinormal distribution 344\#define dim (3) 345int i; 346double mean[dim], covar[dim*dim]; 347UNUR_DISTR *covar_distr; 348UNUR_GEN *covar_gen; 349UNUR_GEN *mean_gen; 350covar_distr = unur_distr_correlation(dim); 351covar_gen = unur_init(unur_mcorr_new(covar_distr)); 352mean_gen = unur_str2gen("normal(5,1)"); 353for (i=0; i<dim; i++) 354 mean[i] = unur_sample_cont(mean_gen); 355do { 356 unur_sample_matr(covar_gen,covar); 357 distr[3] = unur_distr_multinormal(dim,mean,covar); 358} while (distr[3]==NULL); 359unur_distr_free(covar_distr); 360unur_free(covar_gen); 361unur_free(mean_gen); 362\#undef dim 363 364 365# random multinormal distribution 366\#define dim (4) 367int i; 368double mean[dim], covar[dim*dim]; 369UNUR_DISTR *covar_distr; 370UNUR_GEN *covar_gen; 371UNUR_GEN *mean_gen; 372covar_distr = unur_distr_correlation(dim); 373covar_gen = unur_init(unur_mcorr_new(covar_distr)); 374mean_gen = unur_str2gen("normal(5,1)"); 375for (i=0; i<dim; i++) 376 mean[i] = unur_sample_cont(mean_gen); 377do { 378 unur_sample_matr(covar_gen,covar); 379 distr[4] = unur_distr_multinormal(dim,mean,covar); 380} while (distr[4]==NULL); 381unur_distr_free(covar_distr); 382unur_free(covar_gen); 383unur_free(mean_gen); 384\#undef dim 385 386 387# random multinormal distribution 388\#define dim (5) 389int i; 390double mean[dim], covar[dim*dim]; 391UNUR_DISTR *covar_distr; 392UNUR_GEN *covar_gen; 393UNUR_GEN *mean_gen; 394covar_distr = unur_distr_correlation(dim); 395covar_gen = unur_init(unur_mcorr_new(covar_distr)); 396mean_gen = unur_str2gen("normal(5,1)"); 397for (i=0; i<dim; i++) 398 mean[i] = unur_sample_cont(mean_gen); 399do { 400 unur_sample_matr(covar_gen,covar); 401 distr[5] = unur_distr_multinormal(dim,mean,covar); 402} while (distr[5]==NULL); 403unur_distr_free(covar_distr); 404unur_free(covar_gen); 405unur_free(mean_gen); 406\#undef dim 407 408 409# random multinormal distribution 410\#define dim (7) 411int i; 412double mean[dim], covar[dim*dim]; 413UNUR_DISTR *covar_distr; 414UNUR_GEN *covar_gen; 415UNUR_GEN *mean_gen; 416covar_distr = unur_distr_correlation(dim); 417covar_gen = unur_init(unur_mcorr_new(covar_distr)); 418mean_gen = unur_str2gen("normal(5,1)"); 419for (i=0; i<dim; i++) 420 mean[i] = unur_sample_cont(mean_gen); 421do { 422 unur_sample_matr(covar_gen,covar); 423 distr[6] = unur_distr_multinormal(dim,mean,covar); 424} while (distr[6]==NULL); 425unur_distr_free(covar_distr); 426unur_free(covar_gen); 427unur_free(mean_gen); 428\#undef dim 429 430 431# random multinormal distribution 432\#define dim (10) 433int i; 434double mean[dim], covar[dim*dim]; 435UNUR_DISTR *covar_distr; 436UNUR_GEN *covar_gen; 437UNUR_GEN *mean_gen; 438covar_distr = unur_distr_correlation(dim); 439covar_gen = unur_init(unur_mcorr_new(covar_distr)); 440mean_gen = unur_str2gen("normal(5,1)"); 441for (i=0; i<dim; i++) 442 mean[i] = unur_sample_cont(mean_gen); 443do { 444 unur_sample_matr(covar_gen,covar); 445 distr[7] = unur_distr_multinormal(dim,mean,covar); 446} while (distr[7]==NULL); 447unur_distr_free(covar_distr); 448unur_free(covar_gen); 449unur_free(mean_gen); 450\#undef dim 451 452 453# random multinormal distribution 454\#define dim (15) 455int i; 456double mean[dim], covar[dim*dim]; 457UNUR_DISTR *covar_distr; 458UNUR_GEN *covar_gen; 459UNUR_GEN *mean_gen; 460covar_distr = unur_distr_correlation(dim); 461covar_gen = unur_init(unur_mcorr_new(covar_distr)); 462mean_gen = unur_str2gen("normal(5,1)"); 463for (i=0; i<dim; i++) 464 mean[i] = unur_sample_cont(mean_gen); 465do { 466 unur_sample_matr(covar_gen,covar); 467 distr[8] = unur_distr_multinormal(dim,mean,covar); 468} while (distr[8]==NULL); 469unur_distr_free(covar_distr); 470unur_free(covar_gen); 471unur_free(mean_gen); 472\#undef dim 473 474 475# random multinormal distribution 476\#define dim (20) 477int i; 478double mean[dim], covar[dim*dim]; 479UNUR_DISTR *covar_distr; 480UNUR_GEN *covar_gen; 481UNUR_GEN *mean_gen; 482covar_distr = unur_distr_correlation(dim); 483covar_gen = unur_init(unur_mcorr_new(covar_distr)); 484mean_gen = unur_str2gen("normal(5,1)"); 485for (i=0; i<dim; i++) 486 mean[i] = unur_sample_cont(mean_gen); 487do { 488 unur_sample_matr(covar_gen,covar); 489 distr[9] = unur_distr_multinormal(dim,mean,covar); 490} while (distr[9]==NULL); 491unur_distr_free(covar_distr); 492unur_free(covar_gen); 493unur_free(mean_gen); 494\#undef dim 495 496 497# random multinormal distribution 498\#define dim (100) 499int i; 500double mean[dim], covar[dim*dim]; 501UNUR_DISTR *covar_distr; 502UNUR_GEN *covar_gen; 503UNUR_GEN *mean_gen; 504covar_distr = unur_distr_correlation(dim); 505covar_gen = unur_init(unur_mcorr_new(covar_distr)); 506mean_gen = unur_str2gen("normal(5,1)"); 507for (i=0; i<dim; i++) 508 mean[i] = unur_sample_cont(mean_gen); 509do { 510 unur_sample_matr(covar_gen,covar); 511 distr[10] = unur_distr_multinormal(dim,mean,covar); 512} while (distr[10]==NULL); 513unur_distr_free(covar_distr); 514unur_free(covar_gen); 515unur_free(mean_gen); 516\#undef dim 517 518# multinormal distribution with correlation matrix of AR(1) process 519\#define dim (100) 520distr[26] = unur_distr_multinormal_ar1(dim,NULL,0.5); 521\#undef dim 522 523\#define dim (100) 524distr[27] = unur_distr_multinormal_ar1(dim,NULL,0.9); 525\#undef dim 526 527\#define dim (100) 528distr[28] = unur_distr_multinormal_ar1(dim,NULL,0.99); 529\#undef dim 530 531\#define dim (100) 532distr[29] = unur_distr_multinormal_ar1(dim,NULL,0.999); 533\#undef dim 534 535 536# random distribution with non-normal marginals 537\#define dim (5) 538double beta_params[2] = {5.,3.}; 539double gamma_params[1] = {7.}; 540int i; 541double mean[dim], covar[dim*dim]; 542UNUR_DISTR *covar_distr; 543UNUR_GEN *covar_gen; 544UNUR_GEN *mean_gen; 545covar_distr = unur_distr_correlation(dim); 546covar_gen = unur_init(unur_mcorr_new(covar_distr)); 547mean_gen = unur_str2gen("normal(5,1)"); 548distr[11] = unur_distr_cvec_new(dim); 549for (i=0; i<dim; i++) 550 mean[i] = unur_sample_cont(mean_gen); 551unur_distr_cvec_set_mean(distr[11],mean); 552do { 553 unur_sample_matr(covar_gen,covar); 554} while (unur_distr_cvec_set_covar(distr[11],covar) != UNUR_SUCCESS); 555unur_distr_cvec_set_marginal_list(distr[11], 556 unur_distr_normal(NULL,0), 557 unur_distr_cauchy(NULL,0), 558 unur_distr_exponential(NULL,0), 559 unur_distr_beta(beta_params,2), 560 unur_distr_gamma(gamma_params,1)); 561unur_distr_cvec_set_stdmarginal_list(distr[11], 562 unur_distr_normal(NULL,0), 563 unur_distr_cauchy(NULL,0), 564 unur_distr_exponential(NULL,0), 565 unur_distr_beta(beta_params,2), 566 unur_distr_gamma(gamma_params,1)); 567unur_distr_set_name(distr[11],"non-normal"); 568unur_distr_free(covar_distr); 569unur_free(covar_gen); 570unur_free(mean_gen); 571\#undef dim 572 573 574# standard "multinormal" distribution of dimension 1 575distr[12] = unur_distr_multinormal(1,NULL,NULL); 576 577 578# "multinormal" distribution of dimension 1 579\#define dim (1) 580int i; 581double mean[dim], covar[dim*dim]; 582UNUR_DISTR *covar_distr; 583UNUR_GEN *covar_gen; 584UNUR_GEN *mean_gen; 585covar_distr = unur_distr_correlation(dim); 586covar_gen = unur_init(unur_mcorr_new(covar_distr)); 587mean_gen = unur_str2gen("normal(5,1)"); 588for (i=0; i<dim; i++) 589 mean[i] = unur_sample_cont(mean_gen); 590do { 591 unur_sample_matr(covar_gen,covar); 592 distr[13] = unur_distr_multinormal(dim,mean,covar); 593} while (distr[13]==NULL); 594unur_distr_free(covar_distr); 595unur_free(covar_gen); 596unur_free(mean_gen); 597\#undef dim 598 599 600# "invalid" distribution 601# (marginal generators cannot be initialized) 602\#define dim (2) 603double covar[] = { 2., 1., 1., 3. }; 604distr[14] = unur_distr_cvec_new(dim); 605unur_distr_cvec_set_covar(distr[14],covar); 606unur_distr_cvec_set_mean(distr[14],NULL); 607unur_distr_cvec_set_marginal_list(distr[14], 608 unur_distr_normal(NULL,0), 609 unur_distr_cont_new() ); 610unur_distr_cvec_set_stdmarginal_list(distr[14], 611 unur_distr_normal(NULL,0), 612 unur_distr_cont_new() ); 613unur_distr_set_name(distr[14],"no_marginal_generator"); 614\#undef dim 615 616 617# standard multinormal distribution 618distr[15] = unur_distr_multicauchy(3,NULL,NULL); 619 620 621# multicauchy distribution, dim = 3 622double mean[] = { 1., 2., 3. }; 623double covar[] = { 2., 2., 1., 2., 4., 3., 1., 3., 3. }; 624distr[16] = unur_distr_multicauchy(3,mean,covar); 625 626 627# random multicauchy distribution 628\#define dim (2) 629int i; 630double mean[dim], covar[dim*dim]; 631UNUR_DISTR *covar_distr; 632UNUR_GEN *covar_gen; 633UNUR_GEN *mean_gen; 634covar_distr = unur_distr_correlation(dim); 635covar_gen = unur_init(unur_mcorr_new(covar_distr)); 636mean_gen = unur_str2gen("normal(5,1)"); 637for (i=0; i<dim; i++) 638 mean[i] = unur_sample_cont(mean_gen); 639do { 640 unur_sample_matr(covar_gen,covar); 641 distr[17] = unur_distr_multicauchy(dim,mean,covar); 642} while (distr[17]==NULL); 643unur_distr_free(covar_distr); 644unur_free(covar_gen); 645unur_free(mean_gen); 646\#undef dim 647 648 649# random multicauchy distribution 650\#define dim (3) 651int i; 652double mean[dim], covar[dim*dim]; 653UNUR_DISTR *covar_distr; 654UNUR_GEN *covar_gen; 655UNUR_GEN *mean_gen; 656covar_distr = unur_distr_correlation(dim); 657covar_gen = unur_init(unur_mcorr_new(covar_distr)); 658mean_gen = unur_str2gen("normal(5,1)"); 659for (i=0; i<dim; i++) 660 mean[i] = unur_sample_cont(mean_gen); 661do { 662 unur_sample_matr(covar_gen,covar); 663 distr[18] = unur_distr_multicauchy(dim,mean,covar); 664} while (distr[18]==NULL); 665unur_distr_free(covar_distr); 666unur_free(covar_gen); 667unur_free(mean_gen); 668\#undef dim 669 670 671# random multicauchy distribution 672\#define dim (4) 673int i; 674double mean[dim], covar[dim*dim]; 675UNUR_DISTR *covar_distr; 676UNUR_GEN *covar_gen; 677UNUR_GEN *mean_gen; 678covar_distr = unur_distr_correlation(dim); 679covar_gen = unur_init(unur_mcorr_new(covar_distr)); 680mean_gen = unur_str2gen("normal(5,1)"); 681for (i=0; i<dim; i++) 682 mean[i] = unur_sample_cont(mean_gen); 683do { 684 unur_sample_matr(covar_gen,covar); 685 distr[19] = unur_distr_multicauchy(dim,mean,covar); 686} while (distr[19]==NULL); 687unur_distr_free(covar_distr); 688unur_free(covar_gen); 689unur_free(mean_gen); 690\#undef dim 691 692 693# random multicauchy distribution 694\#define dim (5) 695int i; 696double mean[dim], covar[dim*dim]; 697UNUR_DISTR *covar_distr; 698UNUR_GEN *covar_gen; 699UNUR_GEN *mean_gen; 700covar_distr = unur_distr_correlation(dim); 701covar_gen = unur_init(unur_mcorr_new(covar_distr)); 702mean_gen = unur_str2gen("normal(5,1)"); 703for (i=0; i<dim; i++) 704 mean[i] = unur_sample_cont(mean_gen); 705do { 706 unur_sample_matr(covar_gen,covar); 707 distr[20] = unur_distr_multicauchy(dim,mean,covar); 708} while (distr[20]==NULL); 709unur_distr_free(covar_distr); 710unur_free(covar_gen); 711unur_free(mean_gen); 712\#undef dim 713 714 715# random multicauchy distribution 716\#define dim (7) 717int i; 718double mean[dim], covar[dim*dim]; 719UNUR_DISTR *covar_distr; 720UNUR_GEN *covar_gen; 721UNUR_GEN *mean_gen; 722covar_distr = unur_distr_correlation(dim); 723covar_gen = unur_init(unur_mcorr_new(covar_distr)); 724mean_gen = unur_str2gen("normal(5,1)"); 725for (i=0; i<dim; i++) 726 mean[i] = unur_sample_cont(mean_gen); 727do { 728 unur_sample_matr(covar_gen,covar); 729 distr[21] = unur_distr_multicauchy(dim,mean,covar); 730} while (distr[21]==NULL); 731unur_distr_free(covar_distr); 732unur_free(covar_gen); 733unur_free(mean_gen); 734\#undef dim 735 736 737# random multicauchy distribution 738\#define dim (10) 739int i; 740double mean[dim], covar[dim*dim]; 741UNUR_DISTR *covar_distr; 742UNUR_GEN *covar_gen; 743UNUR_GEN *mean_gen; 744covar_distr = unur_distr_correlation(dim); 745covar_gen = unur_init(unur_mcorr_new(covar_distr)); 746mean_gen = unur_str2gen("normal(5,1)"); 747for (i=0; i<dim; i++) 748 mean[i] = unur_sample_cont(mean_gen); 749do { 750 unur_sample_matr(covar_gen,covar); 751 distr[22] = unur_distr_multicauchy(dim,mean,covar); 752} while (distr[22]==NULL); 753unur_distr_free(covar_distr); 754unur_free(covar_gen); 755unur_free(mean_gen); 756\#undef dim 757 758 759# random multicauchy distribution 760\#define dim (15) 761int i; 762double mean[dim], covar[dim*dim]; 763UNUR_DISTR *covar_distr; 764UNUR_GEN *covar_gen; 765UNUR_GEN *mean_gen; 766covar_distr = unur_distr_correlation(dim); 767covar_gen = unur_init(unur_mcorr_new(covar_distr)); 768mean_gen = unur_str2gen("normal(5,1)"); 769for (i=0; i<dim; i++) 770 mean[i] = unur_sample_cont(mean_gen); 771do { 772 unur_sample_matr(covar_gen,covar); 773 distr[23] = unur_distr_multicauchy(dim,mean,covar); 774} while (distr[23]==NULL); 775unur_distr_free(covar_distr); 776unur_free(covar_gen); 777unur_free(mean_gen); 778\#undef dim 779 780 781# random multicauchy distribution 782\#define dim (20) 783int i; 784double mean[dim], covar[dim*dim]; 785UNUR_DISTR *covar_distr; 786UNUR_GEN *covar_gen; 787UNUR_GEN *mean_gen; 788covar_distr = unur_distr_correlation(dim); 789covar_gen = unur_init(unur_mcorr_new(covar_distr)); 790mean_gen = unur_str2gen("normal(5,1)"); 791for (i=0; i<dim; i++) 792 mean[i] = unur_sample_cont(mean_gen); 793do { 794 unur_sample_matr(covar_gen,covar); 795 distr[24] = unur_distr_multicauchy(dim,mean,covar); 796} while (distr[24]==NULL); 797unur_distr_free(covar_distr); 798unur_free(covar_gen); 799unur_free(mean_gen); 800\#undef dim 801 802 803# random multicauchy distribution 804\#define dim (100) 805int i; 806double mean[dim], covar[dim*dim]; 807UNUR_DISTR *covar_distr; 808UNUR_GEN *covar_gen; 809UNUR_GEN *mean_gen; 810covar_distr = unur_distr_correlation(dim); 811covar_gen = unur_init(unur_mcorr_new(covar_distr)); 812mean_gen = unur_str2gen("normal(5,1)"); 813for (i=0; i<dim; i++) 814 mean[i] = unur_sample_cont(mean_gen); 815do { 816 unur_sample_matr(covar_gen,covar); 817 distr[25] = unur_distr_multicauchy(dim,mean,covar); 818} while (distr[25]==NULL); 819unur_distr_free(covar_distr); 820unur_free(covar_gen); 821unur_free(mean_gen); 822\#undef dim 823 824 825# number of distributions: 33 826 827 828[validate - test chi2:] 829 830# + ... pass test 831# 0 ... fail to initialize generator 832# - ... fail test 833# . ... do not run test 834# # ... comment 835# 836# generators: 837# [0] ... default variant 838# [1] ... default variant but reinitialized with changed distribution 839# 840#gen 0 1 # distribution 841#--------------------------------------------- 842 <0> + + # standard multinormal (dim=3) 843 <1> + + # multinormal (dim=3) 844x <2> + . # random multinormal (dim=2) 845x <3> + + # random multinormal (dim=3) 846x <4> + . # random multinormal (dim=4) 847x <5> + . # random multinormal (dim=5) 848x <6> + . # random multinormal (dim=7) 849x <7> + . # random multinormal (dim=10) 850x <8> + . # random multinormal (dim=15) 851x <9> + . # random multinormal (dim=20) 852x<10> + . # random multinormal (dim=100) 853x<26> + . # multinormal with AR(1) corr matrix (rho=0.5, dim=100) 854x<27> + . # multinormal with AR(1) corr matrix (rho=0.9, dim=100) 855 <28> + . # multinormal with AR(1) corr matrix (rho=0.99, dim=100) 856x<29> + . # multinormal with AR(1) corr matrix (rho=0.999, dim=100) 857x<11> + . # random distribution with non-normal marginals (dim=5) 858 <12> + . # standard multinormal (dim=1) 859x<13> + . # random multinormal (dim=1) 860 <14> 0 . # invalid distribution 861 <15> + + # standard multicauchy (dim=3) 862 <16> + + # multicauchy (dim=3) 863x<17> + . # random multicauchy (dim=2) 864x<18> + + # random multicauchy (dim=3) 865x<19> + . # random multicauchy (dim=4) 866x<20> + . # random multicauchy (dim=5) 867x<21> + . # random multicauchy (dim=7) 868x<22> + . # random multicauchy (dim=10) 869x<23> + . # random multicauchy (dim=15) 870x<24> + . # random multicauchy (dim=20) 871x<25> + . # random multicauchy (dim=100) 872x<30> + - # standard multinormal (dim=3) with rectangular domain 873 <31> + . # standard multinormal (dim=3) with rectangular domain 874x<32> + . # standard multinormal (dim=3) with rectangular domain 875 876 877############################################################################# 878############################################################################# 879 880[verbatim] 881 882############################################################################# 883