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

[main]

[main - data:]

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

[main - header:]

/* prototypes */

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

/* sample size for Gaussian distributet sample */
\#define samplesize (5000)

UNUR_DISTR *get_distr_with_data( void );
UNUR_DISTR *get_distr_with_Gaussian_data( void );
double urng_ed (void *dummy);


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

[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 - data missing in distribution object:
   distr = unur_distr_cemp_new();   /* no data given */ ]

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

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

# [set]

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

# [get]

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

# [chg]

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

[init]

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

unur_init( par );
	--> expected_NULL --> UNUR_ERR_NULL


[init - run init:
   distr = get_distr_with_data();
   par = unur_empl_new(distr);
   gen = unur_init( par ); <-- ! NULL ]

# this should be o.k.
	--> none --> 0x0u

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

[reinit]

[reinit - does not exist:
   distr = get_distr_with_data();
   par = unur_empl_new(distr);
   gen = unur_init( par ); <-- ! NULL ]

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

unur_sample_cont( gen );
	--> expected_INFINITY --> UNUR_ERR_GEN_CONDITION


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

[sample]

[sample - compare clone:
   UNUR_GEN *clone;
   distr = get_distr_with_data();
   par = unur_empl_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


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

[sample - compare stringparser:
   double data[] = {1.,2.,3.,4.,5.,6.,7.,8.,9.};
   distr = NULL;
   par = NULL;
   gen = NULL; ]

distr = unur_distr_cemp_new();
unur_distr_cemp_set_data(distr,data,9);
par = unur_empl_new(distr);
gen = unur_init(par);
	-->compare_sequence_gen_start

unur_free(gen); gen = NULL;
unur_distr_free(distr); distr = NULL;
gen = unur_str2gen( "cemp; data = (1.,2.,3.,4.,5.,6.,7.,8.,9.) & \
  method = empl" );
	-->compare_sequence_gen


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

[validate]

[validate - generators:]

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


[validate - distributions:]

# approximate normal distribution
distr[0] = get_distr_with_Gaussian_data();


[validate - test chi2:]

#  + ... pass test
#  0 ... fail to initialize generator
#  - ... fail test
#  . ... do not run test
#  # ... comment
#
# generators:
#   [0] default
#
#	[0]  # distribution
#----------------------------------------------------------------
 <0>	 +   # approximate normal distribution (sample size 200000)


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

[verbatim]

/*---------------------------------------------------------------------------*/

UNUR_DISTR *get_distr_with_data( void )
{
\#define PV_SIZE 20
  double pv[PV_SIZE];
  UNUR_DISTR *distr;
  int i;

  for (i=0; i<PV_SIZE; i++)
    pv[i] = 10. * unur_urng_fish(NULL);

  distr = unur_distr_cemp_new();
  unur_distr_cemp_set_data(distr,pv,PV_SIZE);

  return distr;

\#undef PV_SIZE
} /* end of get_distr_with_data() */

/*---------------------------------------------------------------------------*/

double urng_ed (void *dummy ATTRIBUTE__UNUSED)
{
  static int state = 1;
  static double stepsize = 1./samplesize;

  state = (state+1) % samplesize;
  return ((state+0.5)*stepsize);
}

UNUR_DISTR *get_distr_with_Gaussian_data( void )
{
  double *data;
  UNUR_GEN *normal;
  UNUR_DISTR *distr;
  UNUR_URNG *urng;
  int i;

  urng = unur_urng_fvoid_new(urng_ed, NULL);

  data = malloc(samplesize*sizeof(double));
  normal = unur_str2gen("normal & method = hinv");
  unur_chg_urng(normal,urng);

  for (i=0;i<samplesize;i++)
  data[i] = unur_sample_cont(normal);

  distr = unur_distr_cemp_new();
  unur_distr_cemp_set_data(distr,data,samplesize);

  free(data);
  unur_free(normal);
  unur_urng_free(urng);

  return distr;
}

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