#############################################################################

[main]

[main - data:]

# method (for information only: the program scans the file name)
method: MVSTD

[main - header:]

/* prototypes */

\#define COMPARE_SAMPLE_SIZE  (500)
\#define VIOLATE_SAMPLE_SIZE  (20)

/* \#define SEED   (298346) */

/* we need marginal distributions for the chi2 tests */
\#define unur_distr_multinormal  unur_distr_multinormal_w_marginals

#############################################################################

[new]

[new - invalid NULL ptr: 
   distr = NULL; ]

~( distr );
	--> expected_NULL --> UNUR_ERR_NULL

[new - invalid distribution type:
   distr = unur_distr_cont_new(); ]

~( distr );
	 --> expected_NULL --> UNUR_ERR_DISTR_INVALID

[new - not a standard distribution:
   distr = unur_distr_cvec_new(3); ]

~( distr );
	--> expected_NULL --> UNUR_ERR_DISTR_INVALID

#############################################################################

# [set]

#############################################################################

# [get]

#############################################################################

# [chg]

#############################################################################

# [init]

#############################################################################

[reinit]

[reinit - exists:
   distr = unur_distr_multinormal(3,NULL,NULL);
   par = unur_mvstd_new(distr);
   gen = unur_init( par ); <-- ! NULL ]

unur_reinit( gen );
	--> expected_reinit

#############################################################################

[sample]

[sample - compare clone:
   const int dim = 3;
   double mean[] = {1.,2.,3.};
   double covar[] = { 2., 2., 1.,   2., 4., 3.,   1., 3., 3. };
   UNUR_GEN *clone;
   distr = unur_distr_multinormal( dim, mean, covar );
   par = NULL;
   gen = NULL; ]

/* normal distribution */
par = unur_mvstd_new(distr);
gen = unur_init( par );
	-->compare_sequence_gen_start

/* clone */
clone = unur_gen_clone(gen);
unur_free(gen);
gen = clone;
	-->compare_sequence_gen


#############################################################################

[validate]

[validate - generators:]

# default program
par[0] = unur_mvstd_new(@distr@);

# default variant but reinitialized with changed distribution
{ UNUR_DISTR *dg =NULL;
double mean[]  = { -1., 2., -3. };
double covar[] = { 1., 0.8, 0.64,   0.8, 1., 0.8,   0.64, 0.8, 1. };
par[1] = unur_mvstd_new(@distr@);
dg = unur_get_distr(gen);
unur_distr_cvec_set_mean(dg,mean);
unur_distr_cvec_set_covar(dg,covar);
unur_reinit(gen); }


[validate - distributions:]

# standard multinormal distribution
distr[0] = unur_distr_multinormal(3,NULL,NULL);

# multinormal distribution, dim = 3 
double mean[]  = { -1., 2., -3. };
double covar[] = { 1., 0.8, 0.64,   0.8, 1., 0.8,   0.64, 0.8, 1. };
distr[1] = unur_distr_multinormal(3,mean,covar);

# random multinormal distribution
\#define dim (2)
int i;
double mean[dim], covar[dim*dim];
UNUR_DISTR *covar_distr;
UNUR_GEN *covar_gen;
UNUR_GEN *mean_gen;
covar_distr = unur_distr_correlation(dim);
covar_gen = unur_init(unur_mcorr_new(covar_distr));
mean_gen = unur_str2gen("normal(5,1)");
for (i=0; i<dim; i++) 
   mean[i] = unur_sample_cont(mean_gen);
do { 
   unur_sample_matr(covar_gen,covar);
   distr[2] = unur_distr_multinormal(dim,mean,covar); 
} while (distr[2]==NULL);
unur_distr_free(covar_distr);
unur_free(covar_gen);
unur_free(mean_gen); 
\#undef dim


# random multinormal distribution
\#define dim (3)
int i;
double mean[dim], covar[dim*dim];
UNUR_DISTR *covar_distr;
UNUR_GEN *covar_gen;
UNUR_GEN *mean_gen;
covar_distr = unur_distr_correlation(dim);
covar_gen = unur_init(unur_mcorr_new(covar_distr));
mean_gen = unur_str2gen("normal(5,1)");
for (i=0; i<dim; i++) 
   mean[i] = unur_sample_cont(mean_gen);
do { 
   unur_sample_matr(covar_gen,covar);
   distr[3] = unur_distr_multinormal(dim,mean,covar); 
} while (distr[3]==NULL);
unur_distr_free(covar_distr);
unur_free(covar_gen);
unur_free(mean_gen); 
\#undef dim


# random multinormal distribution
\#define dim (4)
int i;
double mean[dim], covar[dim*dim];
UNUR_DISTR *covar_distr;
UNUR_GEN *covar_gen;
UNUR_GEN *mean_gen;
covar_distr = unur_distr_correlation(dim);
covar_gen = unur_init(unur_mcorr_new(covar_distr));
mean_gen = unur_str2gen("normal(5,1)");
for (i=0; i<dim; i++) 
   mean[i] = unur_sample_cont(mean_gen);
do { 
   unur_sample_matr(covar_gen,covar);
   distr[4] = unur_distr_multinormal(dim,mean,covar); 
} while (distr[4]==NULL);
unur_distr_free(covar_distr);
unur_free(covar_gen);
unur_free(mean_gen); 
\#undef dim


# random multinormal distribution
\#define dim (5)
int i;
double mean[dim], covar[dim*dim];
UNUR_DISTR *covar_distr;
UNUR_GEN *covar_gen;
UNUR_GEN *mean_gen;
covar_distr = unur_distr_correlation(dim);
covar_gen = unur_init(unur_mcorr_new(covar_distr));
mean_gen = unur_str2gen("normal(5,1)");
for (i=0; i<dim; i++) 
   mean[i] = unur_sample_cont(mean_gen);
do { 
   unur_sample_matr(covar_gen,covar);
   distr[5] = unur_distr_multinormal(dim,mean,covar); 
} while (distr[5]==NULL);
unur_distr_free(covar_distr);
unur_free(covar_gen);
unur_free(mean_gen); 
\#undef dim


# random multinormal distribution
\#define dim (7)
int i;
double mean[dim], covar[dim*dim];
UNUR_DISTR *covar_distr;
UNUR_GEN *covar_gen;
UNUR_GEN *mean_gen;
covar_distr = unur_distr_correlation(dim);
covar_gen = unur_init(unur_mcorr_new(covar_distr));
mean_gen = unur_str2gen("normal(5,1)");
for (i=0; i<dim; i++) 
   mean[i] = unur_sample_cont(mean_gen);
do { 
   unur_sample_matr(covar_gen,covar);
   distr[6] = unur_distr_multinormal(dim,mean,covar); 
} while (distr[6]==NULL);
unur_distr_free(covar_distr);
unur_free(covar_gen);
unur_free(mean_gen); 
\#undef dim


# random multinormal distribution
\#define dim (10)
int i;
double mean[dim], covar[dim*dim];
UNUR_DISTR *covar_distr;
UNUR_GEN *covar_gen;
UNUR_GEN *mean_gen;
covar_distr = unur_distr_correlation(dim);
covar_gen = unur_init(unur_mcorr_new(covar_distr));
mean_gen = unur_str2gen("normal(5,1)");
for (i=0; i<dim; i++) 
   mean[i] = unur_sample_cont(mean_gen);
do { 
   unur_sample_matr(covar_gen,covar);
   distr[7] = unur_distr_multinormal(dim,mean,covar); 
} while (distr[7]==NULL);
unur_distr_free(covar_distr);
unur_free(covar_gen);
unur_free(mean_gen); 
\#undef dim


# random multinormal distribution
\#define dim (15)
int i;
double mean[dim], covar[dim*dim];
UNUR_DISTR *covar_distr;
UNUR_GEN *covar_gen;
UNUR_GEN *mean_gen;
covar_distr = unur_distr_correlation(dim);
covar_gen = unur_init(unur_mcorr_new(covar_distr));
mean_gen = unur_str2gen("normal(5,1)");
for (i=0; i<dim; i++) 
   mean[i] = unur_sample_cont(mean_gen);
do { 
   unur_sample_matr(covar_gen,covar);
   distr[8] = unur_distr_multinormal(dim,mean,covar); 
} while (distr[8]==NULL);
unur_distr_free(covar_distr);
unur_free(covar_gen);
unur_free(mean_gen); 
\#undef dim


# random multinormal distribution
\#define dim (20)
int i;
double mean[dim], covar[dim*dim];
UNUR_DISTR *covar_distr;
UNUR_GEN *covar_gen;
UNUR_GEN *mean_gen;
covar_distr = unur_distr_correlation(dim);
covar_gen = unur_init(unur_mcorr_new(covar_distr));
mean_gen = unur_str2gen("normal(5,1)");
for (i=0; i<dim; i++) 
   mean[i] = unur_sample_cont(mean_gen);
do { 
   unur_sample_matr(covar_gen,covar);
   distr[9] = unur_distr_multinormal(dim,mean,covar); 
} while (distr[9]==NULL);
unur_distr_free(covar_distr);
unur_free(covar_gen);
unur_free(mean_gen); 
\#undef dim


# random multinormal distribution
\#define dim (100)
int i;
double mean[dim], covar[dim*dim];
UNUR_DISTR *covar_distr;
UNUR_GEN *covar_gen;
UNUR_GEN *mean_gen;
covar_distr = unur_distr_correlation(dim);
covar_gen = unur_init(unur_mcorr_new(covar_distr));
mean_gen = unur_str2gen("normal(5,1)");
for (i=0; i<dim; i++) 
   mean[i] = unur_sample_cont(mean_gen);
do { 
   unur_sample_matr(covar_gen,covar);
   distr[10] = unur_distr_multinormal(dim,mean,covar); 
} while (distr[10]==NULL);
unur_distr_free(covar_distr);
unur_free(covar_gen);
unur_free(mean_gen); 
\#undef dim


# multinormal distribution with correlation matrix of AR(1) process
\#define dim (100)
distr[11] = unur_distr_multinormal_ar1(dim,NULL,0.5);
\#undef dim

\#define dim (100)
distr[12] = unur_distr_multinormal_ar1(dim,NULL,0.9);
\#undef dim

\#define dim (100)
distr[13] = unur_distr_multinormal_ar1(dim,NULL,0.99);
\#undef dim

\#define dim (100)
distr[14] = unur_distr_multinormal_ar1(dim,NULL,0.999);
\#undef dim

# standard "multinormal" distribution of dimension 1
distr[15] = unur_distr_multinormal(1,NULL,NULL);

# "multinormal" distribution of dimension 1
\#define dim (1)
int i;
double mean[dim], covar[dim*dim];
UNUR_DISTR *covar_distr;
UNUR_GEN *covar_gen;
UNUR_GEN *mean_gen;
covar_distr = unur_distr_correlation(dim);
covar_gen = unur_init(unur_mcorr_new(covar_distr));
mean_gen = unur_str2gen("normal(5,1)");
for (i=0; i<dim; i++) 
   mean[i] = unur_sample_cont(mean_gen);
do { 
   unur_sample_matr(covar_gen,covar);
   distr[16] = unur_distr_multinormal(dim,mean,covar); 
} while (distr[16]==NULL);
unur_distr_free(covar_distr);
unur_free(covar_gen);
unur_free(mean_gen); 
\#undef dim

# standard multinormal distribution with rectangular domain
double ll[3] = {0.,0.,0.};
double ru[3] = {UNUR_INFINITY,UNUR_INFINITY,UNUR_INFINITY};
distr[17] = unur_distr_multinormal(3,NULL,NULL);
unur_distr_cvec_set_domain_rect(distr[17],ll,ru);

# standard multicauchy distribution
distr[18] = unur_distr_multicauchy(3,NULL,NULL);


# number of distributions: 19


[validate - test chi2:]

#  + ... pass test
#  0 ... fail to initialize generator (given variant does not exist)
#  - ... fail test
#  / ... either init fails or test passes
#  . ... do not run test
#  # ... comment
#
# generators:
#  [0] ... default variant
#  [1] ... default variant but reinitialized with changed distribution
#
#gen	0  1	# distribution
#---------------------------------------------
  <0>	+  +	# standard multinormal (dim=3)
  <1>	+  +	# multinormal (dim=3)
  <2>	+  .	# random multinormal (dim=2)
  <3>	+  +	# random multinormal (dim=3)
  <4>	+  .	# random multinormal (dim=4)
  <5>	+  .	# random multinormal (dim=5)
  <6>	+  .	# random multinormal (dim=7)
  <7>	+  .	# random multinormal (dim=10)
  <8>	+  .	# random multinormal (dim=15)
  <9>	+  .	# random multinormal (dim=20)
 <10>	+  .	# random multinormal (dim=100)
x<11>	+  .	# multinormal with AR(1) corr matrix (rho=0.5, dim=100)
 <12>	+  .	# multinormal with AR(1) corr matrix (rho=0.9, dim=100)
x<13>	+  .	# multinormal with AR(1) corr matrix (rho=0.99, dim=100)
x<14>	+  .	# multinormal with AR(1) corr matrix (rho=0.999, dim=100)
 <15>	+  .	# standard multinormal (dim=1)
x<16>	+  .	# random multinormal (dim=1)
 <17>	0  .	# standard multinormal distribution with rectangular domain
 <18>	0  .	# invalid distribution (standard multicauchy, dim=3)


#############################################################################
#############################################################################

[verbatim]

#############################################################################
