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

[main]

[main - data:]

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

[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:
   distr = unur_distr_cvemp_new(2); ]

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


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

[set]

[set - invalid NULL ptr: 
   par = NULL; ]

~_smoothing( par, 1. );
        --> expected_setfailed --> UNUR_ERR_NULL

~_varcor( par, 1 );
        --> expected_setfailed --> UNUR_ERR_NULL


[set - invalid parameter object:
   distr = unur_distr_normal(NULL,0);
   par = unur_tdr_new(distr); ]

~_smoothing( par, 1. );
        --> expected_setfailed --> UNUR_ERR_PAR_INVALID

~_varcor( par, 1 );
        --> expected_setfailed --> UNUR_ERR_PAR_INVALID

unur_par_free (par);

[set - invalid parameters:
   double data[] = {1.,1.,-1.,1.,1.,-1.,-1.,-1. };
   distr = unur_distr_cvemp_new(2);
   unur_distr_cvemp_set_data(distr, data, 4); 
   par = unur_vempk_new(distr); ]

~_smoothing( par, -1. );
        --> expected_setfailed --> UNUR_ERR_PAR_SET

unur_par_free(par);


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

# [get]

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

[chg]

[chg - invalid NULL ptr: 
   gen = NULL; ]

~_smoothing( gen, 1.);
        --> expected_setfailed --> UNUR_ERR_NULL

~_varcor( gen, 1 );
        --> expected_setfailed --> UNUR_ERR_NULL


[chg - invalid generator object:
   gen = unur_str2gen("normal"); <-- ! NULL ]

~_smoothing( gen, 1.);
        --> expected_setfailed --> UNUR_ERR_GEN_INVALID

~_varcor( gen, 1 );
        --> expected_setfailed --> UNUR_ERR_GEN_INVALID


[chg - invalid parameters:
   double data[] = {1.,1.,-1.,1.,1.,-1.,-1.,-1. };
   distr = unur_distr_cvemp_new(2);
   unur_distr_cvemp_set_data(distr, data, 4); 
   par = unur_vempk_new(distr);
   gen = unur_init(par);  <-- ! NULL ]

~_smoothing( gen, -1.);
        --> expected_setfailed --> UNUR_ERR_PAR_SET


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

# [init]

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

[reinit]

[reinit - does not exist:
   double x[2];
   double data[] = {1.,1.,-1.,1.,1.,-1.,-1.,-1. };
   distr = unur_distr_cvemp_new(2);
   unur_distr_cvemp_set_data(distr, data, 4); 
   par = unur_vempk_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:
   double data[] = {1.,1.,-1.,1.,1.,-1.,-1.,-1. };
   UNUR_GEN *clone = NULL;
   distr = unur_distr_cvemp_new(2);
   unur_distr_cvemp_set_data(distr, data, 4); 
   par = unur_vempk_new(distr);
   gen = unur_init(par);   <-- ! NULL ]

/* default generator object */
        -->compare_sequence_gen_start

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

/* set smoothing factor */
unur_free(gen);
par = unur_vempk_new(distr);
unur_vempk_set_smoothing( par, 3. );
gen = unur_init( par );
        -->compare_sequence_gen_start

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

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

#[sample - compare stringparser:
#   distr = NULL;
#   par = NULL;
#   gen = NULL; ]
#
# Not implemented yet!
#

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

[validate]

[validate - generators:]

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

# use variance correction
par[1] = unur_vempk_new(@distr@);
unur_vempk_set_varcor(par,TRUE);


[validate - distributions:]

# approximate normal distribution
\#define dim (2)
{ double *data;
  UNUR_DISTR *dist_mnormal;
  UNUR_GEN *gen_mnormal;
  int i;
  const int ss = 100000;
  data = malloc(dim*ss*sizeof(double));
  dist_mnormal = unur_distr_multinormal(dim,NULL,NULL);
  gen_mnormal = unur_init(unur_mvstd_new(dist_mnormal));
  for (i=0;i<ss;i++)
	unur_sample_vec(gen_mnormal, data+i*dim);
  unur_free(gen_mnormal);
  unur_distr_free(dist_mnormal);
  distr[0] = unur_distr_cvemp_new(dim);
  unur_distr_cvemp_set_data(distr[0],data,ss);
  free(data); }
\#undef dim

# approximate normal distribution
\#define dim (3)
{ double *data;
  UNUR_DISTR *dist_mnormal;
  UNUR_GEN *gen_mnormal;
  int i;
  const int ss = 100000;
  data = malloc(dim*ss*sizeof(double));
  dist_mnormal = unur_distr_multinormal(dim,NULL,NULL);
  gen_mnormal = unur_init(unur_mvstd_new(dist_mnormal));
  for (i=0;i<ss;i++)
	unur_sample_vec(gen_mnormal, data+i*dim);
  unur_free(gen_mnormal);
  unur_distr_free(dist_mnormal);
  distr[1] = unur_distr_cvemp_new(dim);
  unur_distr_cvemp_set_data(distr[1],data,ss);
  free(data); }
\#undef dim


[validate - test chi2:]

#  + ... pass test
#  0 ... fail to initialize generator
#  - ... fail test
#  . ... do not run test
#  # ... comment
#
# generators:
#   [0] default
#   [1] use variance correction
#
#	[0]  [1]	# distribution
#----------------------------------------------------------------
 <0>	 +    +		# approximate normal distribution (dim=2, sample size 100000)
 <1>	 +    +		# approximate normal distribution (dim=3, sample size 100000)


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

[verbatim]

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