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

[main]

[main - data:]

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

[main - header:]

/* prototypes */

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

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

[new]

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

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


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

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


[new - data missing in distribution object:
   double mean[] = {1.,2.};
   double covar[] = {2.,1., 1., 2.};
   distr = unur_distr_cvec_new(2); ]

/* mean */
~( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_REQUIRED

/* covariance matrix */
unur_distr_cvec_set_mean(distr,mean);
unur_distr_cvec_set_covar(distr,covar);
~( distr );
        --> expected_NULL --> UNUR_ERR_DISTR_REQUIRED


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

# [set]

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

# [get]

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

# [chg]

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

# [init]

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

[reinit]

[reinit - does not exist:
   double x[3];
   const int dim = 3;
   double rankcorr[] = { 1., 0.5, 0.1,  0.5, 1., 0.3,  0.1, 0.3, 1. };
   distr = unur_distr_copula(dim, rankcorr);
   par = unur_norta_new(distr);
   gen = unur_init( par ); <-- ! NULL ]

unur_reinit( gen );
	--> expected_setfailed --> UNUR_ERR_NO_REINIT

unur_sample_vec( gen, x );
x[0];
	--> expected_INFINITY --> UNUR_ERR_GEN_CONDITION


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

[sample]

[sample - compare clone:
   const int dim = 3;
   UNUR_GEN *clone;
   distr = unur_distr_copula(dim, NULL);
   par = unur_norta_new(distr);
   gen = unur_init( par ); <-- ! NULL ]

/* copula without correlation */
	-->compare_sequence_gen_start

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

#.....................................................................

[sample - compare clone:
   const int dim = 3;
   double rankcorr[] = { 1., 0.5, 0.1,  0.5, 1., 0.3,  0.1, 0.3, 1. };
   UNUR_GEN *clone;
   distr = unur_distr_copula(dim, rankcorr);
   par = unur_norta_new(distr);
   gen = unur_init( par ); <-- ! NULL ]

/* copula with correlation */
	-->compare_sequence_gen_start

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

#.....................................................................

[sample - compare clone:
   const int dim = 3;
   double rankcorr[] = { 1., 0.5, 0.1,  0.5, 1., 0.3,  0.1, 0.3, 1. };
   double gamma_params[] = {5.};
   UNUR_GEN *clone;
   UNUR_DISTR *marginal;
   distr = unur_distr_cvec_new(dim);
   unur_distr_cvec_set_rankcorr(distr,rankcorr);
   marginal = unur_distr_gamma(gamma_params,1);
   unur_distr_cvec_set_marginals(distr,marginal);
   unur_distr_free(marginal);
   par = unur_norta_new(distr);
   gen = unur_init( par ); <-- ! NULL ]

/* gamma marginals with correlation */
	-->compare_sequence_gen_start

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

#.....................................................................

[sample - compare clone:
   const int dim = 3;
   double rankcorr[] = { 1., 0.5, 0.1,  0.5, 1., 0.3,  0.1, 0.3, 1. };
   double gamma_params[] = {5.};
   double beta_params[] = {3.,5.};
   UNUR_GEN *clone;
   distr = unur_distr_cvec_new(dim);
   unur_distr_cvec_set_rankcorr(distr,rankcorr);
   unur_distr_cvec_set_marginal_list(distr,
        unur_distr_cauchy(NULL,0),
        unur_distr_gamma(gamma_params,1),
        unur_distr_beta(beta_params,2) );
   par = unur_norta_new(distr);
   gen = unur_init( par ); <-- ! NULL ]

/* multivariate distribution with given marginals */
        -->compare_sequence_gen_start

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

#.....................................................................

[sample - compare clone:
   double rankcorr[] = { 1., 0.5, 0.1,  0.5, 1., 0.3,  0.1, 0.3, 1. };
   double gamma_params[] = {5.};
   double beta_params[] = {3.,5.};
   UNUR_GEN *clone;
   UNUR_DISTR *marginals[3];
   distr = unur_distr_cvec_new(3);
   unur_distr_cvec_set_rankcorr(distr,rankcorr);
   marginals[0] = unur_distr_gamma(gamma_params,1);
   marginals[1] = unur_distr_cauchy(NULL,0);
   marginals[2] = unur_distr_beta(beta_params,2);
   unur_distr_cvec_set_marginal_array(distr,marginals);
   unur_distr_free(marginals[0]);
   unur_distr_free(marginals[1]);
   unur_distr_free(marginals[2]);
   par = unur_norta_new(distr);
   gen = unur_init( par ); <-- ! NULL ]

/* multivariate distribution with given marginals */
	-->compare_sequence_gen_start

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

#.....................................................................

[sample - compare clone 1dim:
   const int dim = 1;
   double beta_params[] = {3.,5.};
   UNUR_GEN *clone;
   distr = unur_distr_cvec_new(dim);
   unur_distr_cvec_set_rankcorr(distr,NULL);
   unur_distr_cvec_set_marginal_list(distr,
	unur_distr_beta(beta_params,2) );
   par = unur_norta_new(distr);
   gen = unur_init( par ); <-- ! NULL ]

/* multivariate distribution with given marginals */
	-->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_norta_new(@distr@);

[validate - distributions:]

# copula without correlation
distr[0] = unur_distr_copula(3,NULL);

# copula with correlation
double rankcorr[] = { 1., 0.5, 0.1,  0.5, 1., 0.3,  0.1, 0.3, 1. };
distr[1] = unur_distr_copula(3, rankcorr);

# gamma marginals
\#define dim (3)
double rankcorr[] = { 1., 0.5, 0.1,  0.5, 1., 0.3,  0.1, 0.3, 1. };
double gamma_params[] = {5.};
UNUR_DISTR *marginal;
distr[2] = unur_distr_cvec_new(dim);
unur_distr_cvec_set_rankcorr(distr[2],rankcorr);
marginal = unur_distr_gamma(gamma_params,1);
unur_distr_cvec_set_marginals(distr[2],marginal);
unur_distr_free(marginal);
unur_distr_set_name(distr[2],"gamma marginals");
\#undef dim


# gamma-cauchy-beta marginals
\#define dim (3)
double rankcorr[] = { 1., 0.5, 0.1,  0.5, 1., 0.3,  0.1, 0.3, 1. };
double gamma_params[] = {5.};
double beta_params[] = {3.,5.};
distr[3] = unur_distr_cvec_new(dim);
unur_distr_cvec_set_rankcorr(distr[3],rankcorr);
unur_distr_cvec_set_marginal_list(distr[3],
	unur_distr_gamma(gamma_params,1),
	unur_distr_cauchy(NULL,0),
	unur_distr_beta(beta_params,2) );
unur_distr_set_name(distr[3],"gamma-cauchy-beta marginals");
\#undef dim


# copula with random correlations
\#define dim (3)
UNUR_DISTR *corr_distr;
UNUR_GEN *corr_gen;
double corr[dim*dim];
corr_distr = unur_distr_correlation(dim);
corr_gen = unur_init(unur_mcorr_new(corr_distr));
do { 
   unur_sample_matr(corr_gen,corr);
   distr[4] = unur_distr_copula(dim, corr);
} while (distr[4]==NULL);
unur_distr_free(corr_distr);
unur_free(corr_gen);
unur_distr_set_name(distr[4],"copula with random correlations");
\#undef dim

# copula with random correlations
\#define dim (10)
UNUR_DISTR *corr_distr;
UNUR_GEN *corr_gen;
double corr[dim*dim];
corr_distr = unur_distr_correlation(dim);
corr_gen = unur_init(unur_mcorr_new(corr_distr));
do { 
   unur_sample_matr(corr_gen,corr);
   distr[5] = unur_distr_copula(dim, corr);
} while (distr[5]==NULL);
unur_distr_free(corr_distr);
unur_free(corr_gen);
unur_distr_set_name(distr[5],"copula with random correlations");
\#undef dim

# copula with random correlations
\#define dim (30)
UNUR_DISTR *corr_distr;
UNUR_GEN *corr_gen;
double corr[dim*dim];
corr_distr = unur_distr_correlation(dim);
corr_gen = unur_init(unur_mcorr_new(corr_distr));
do { 
   unur_sample_matr(corr_gen,corr);
   distr[6] = unur_distr_copula(dim, corr);
} while (distr[6]==NULL);
unur_distr_free(corr_distr);
unur_free(corr_gen);
unur_distr_set_name(distr[6],"copula with random correlations");
\#undef dim

# copula with random correlations
\#define dim (100)
UNUR_DISTR *corr_distr;
UNUR_GEN *corr_gen;
double corr[dim*dim];
corr_distr = unur_distr_correlation(dim);
corr_gen = unur_init(unur_mcorr_new(corr_distr));
do { 
   unur_sample_matr(corr_gen,corr);
   distr[7] = unur_distr_copula(dim, corr);
} while (distr[7]==NULL);
unur_distr_free(corr_distr);
unur_free(corr_gen);
unur_distr_set_name(distr[7],"copula with random correlations");
\#undef dim

# gamma marginals with rectangular domain
\#define dim (3)
double ll[3] = {0.,1.,0.};
double ru[3] = {1.,UNUR_INFINITY,UNUR_INFINITY};
#double rankcorr[] = { 1., 0.5, 0.1,  0.5, 1., 0.3,  0.1, 0.3, 1. };
double rankcorr[] = { 1., 0., 0.,  0., 1., 0.,  0., 0., 1. };
double gamma_params[] = {5.};
UNUR_DISTR *marginal;
distr[8] = unur_distr_cvec_new(dim);
unur_distr_cvec_set_rankcorr(distr[8],rankcorr);
marginal = unur_distr_gamma(gamma_params,1);
unur_distr_cvec_set_marginals(distr[8],marginal);
unur_distr_cvec_set_domain_rect(distr[8],ll,ru);
unur_distr_free(marginal);
unur_distr_set_name(distr[8],"gamma marginals with rectangular domain");
\#undef dim

# gamma marginals with rectangular domain
\#define dim (3)
double ll[3] = {0.,1.,2.};
double ru[3] = {1.,2., 3.};
double rankcorr[] = { 1., 0.5, 0.1,  0.5, 1., 0.3,  0.1, 0.3, 1. };
double gamma_params[] = {5.};
UNUR_DISTR *marginal;
distr[9] = unur_distr_cvec_new(dim);
unur_distr_cvec_set_rankcorr(distr[9],rankcorr);
marginal = unur_distr_gamma(gamma_params,1);
unur_distr_cvec_set_marginals(distr[9],marginal);
unur_distr_cvec_set_domain_rect(distr[9],ll,ru);
unur_distr_free(marginal);
unur_distr_set_name(distr[9],"gamma marginals with rectangular domain");
\#undef dim

# gamma marginals with rectangular domain
\#define dim (3)
double ll[3] = {0.,1.,2.};
double ru[3] = {1.,2., 3.};
double rankcorr[] = { 1., 0.5, 0.1,  0.5, 1., 0.3,  0.1, 0.3, 1. };
double gamma_params[] = {5.};
distr[10] = unur_distr_cvec_new(dim);
unur_distr_cvec_set_rankcorr(distr[10],rankcorr);
unur_distr_cvec_set_marginal_list(distr[10],
	unur_distr_gamma(gamma_params,1),
	unur_distr_gamma(gamma_params,1),
	unur_distr_gamma(gamma_params,1));
unur_distr_cvec_set_domain_rect(distr[10],ll,ru);
unur_distr_set_name(distr[10],"gamma marginals with rectangular domain");
\#undef dim

# number of distributions: 11


[validate - test chi2:]

#  + ... pass test
#  0 ... fail to initialize generator
#  - ... fail test
#  . ... do not run test
#  # ... comment
#
# generators:
#  [0] ... default variant
#
#gen	0	# distribution
#---------------------------------------------
  <0>	+	# copula without correlations (dim=3)
  <1>	+	# copula with correlations (dim=3)
  <2>	+	# gamma marginals (dim=3)
  <3>	+	# gamma-cauchy-beta marginals (dim=3)
  <4>	+	# copula with random correlations (dim=3)
  <5>	+	# copula with random correlations (dim=10)
  <6>	+	# copula with random correlations (dim=30)
  <7>	+	# copula with random correlations (dim=100)
  <8>	+	# gamma marginals with rectangular domain
  <9>	+	# gamma marginals with rectangular domain
 <10>	+	# gamma marginals with rectangular domain


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

[verbatim]

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