1# $Id: t_vempk.conf 5330 2011-04-19 10:50:18Z leydold $
2#############################################################################
3
4[main]
5
6[main - data:]
7
8# method (for information only: the program scans the file name)
9method: VEMPK
10
11[main - header:]
12
13/* prototypes */
14
15\#define COMPARE_SAMPLE_SIZE   (10000)
16\#define VIOLATE_SAMPLE_SIZE   (20)
17
18#############################################################################
19
20[new]
21
22[new - invalid NULL ptr:
23   distr = NULL; ]
24
25~( distr );
26        --> expected_NULL --> UNUR_ERR_NULL
27
28
29[new - invalid distribution type:
30   distr = unur_distr_discr_new(); ]
31
32~( distr );
33         --> expected_NULL --> UNUR_ERR_DISTR_INVALID
34
35
36[new - data missing in distribution object:
37   distr = unur_distr_cvemp_new(2); ]
38
39/* data */
40~( distr );
41        --> expected_NULL --> UNUR_ERR_DISTR_REQUIRED
42
43
44#############################################################################
45
46[set]
47
48[set - invalid NULL ptr:
49   par = NULL; ]
50
51~_smoothing( par, 1. );
52        --> expected_setfailed --> UNUR_ERR_NULL
53
54~_varcor( par, 1 );
55        --> expected_setfailed --> UNUR_ERR_NULL
56
57
58[set - invalid parameter object:
59   distr = unur_distr_normal(NULL,0);
60   par = unur_tdr_new(distr); ]
61
62~_smoothing( par, 1. );
63        --> expected_setfailed --> UNUR_ERR_PAR_INVALID
64
65~_varcor( par, 1 );
66        --> expected_setfailed --> UNUR_ERR_PAR_INVALID
67
68unur_par_free (par);
69
70[set - invalid parameters:
71   double data[] = {1.,1.,-1.,1.,1.,-1.,-1.,-1. };
72   distr = unur_distr_cvemp_new(2);
73   unur_distr_cvemp_set_data(distr, data, 4);
74   par = unur_vempk_new(distr); ]
75
76~_smoothing( par, -1. );
77        --> expected_setfailed --> UNUR_ERR_PAR_SET
78
79unur_par_free(par);
80
81
82#############################################################################
83
84# [get]
85
86#############################################################################
87
88[chg]
89
90[chg - invalid NULL ptr:
91   gen = NULL; ]
92
93~_smoothing( gen, 1.);
94        --> expected_setfailed --> UNUR_ERR_NULL
95
96~_varcor( gen, 1 );
97        --> expected_setfailed --> UNUR_ERR_NULL
98
99
100[chg - invalid generator object:
101   gen = unur_str2gen("normal"); <-- ! NULL ]
102
103~_smoothing( gen, 1.);
104        --> expected_setfailed --> UNUR_ERR_GEN_INVALID
105
106~_varcor( gen, 1 );
107        --> expected_setfailed --> UNUR_ERR_GEN_INVALID
108
109
110[chg - invalid parameters:
111   double data[] = {1.,1.,-1.,1.,1.,-1.,-1.,-1. };
112   distr = unur_distr_cvemp_new(2);
113   unur_distr_cvemp_set_data(distr, data, 4);
114   par = unur_vempk_new(distr);
115   gen = unur_init(par);  <-- ! NULL ]
116
117~_smoothing( gen, -1.);
118        --> expected_setfailed --> UNUR_ERR_PAR_SET
119
120
121#############################################################################
122
123# [init]
124
125#############################################################################
126
127[reinit]
128
129[reinit - does not exist:
130   double x[2];
131   double data[] = {1.,1.,-1.,1.,1.,-1.,-1.,-1. };
132   distr = unur_distr_cvemp_new(2);
133   unur_distr_cvemp_set_data(distr, data, 4);
134   par = unur_vempk_new(distr);
135   gen = unur_init( par ); <-- ! NULL ]
136
137unur_reinit( gen );
138	--> expected_setfailed --> UNUR_ERR_NO_REINIT
139
140unur_sample_vec( gen, x );
141x[0];
142	--> expected_INFINITY --> UNUR_ERR_GEN_CONDITION
143
144
145#############################################################################
146
147[sample]
148
149[sample - compare clone:
150   double data[] = {1.,1.,-1.,1.,1.,-1.,-1.,-1. };
151   UNUR_GEN *clone = NULL;
152   distr = unur_distr_cvemp_new(2);
153   unur_distr_cvemp_set_data(distr, data, 4);
154   par = unur_vempk_new(distr);
155   gen = unur_init(par);   <-- ! NULL ]
156
157/* default generator object */
158        -->compare_sequence_gen_start
159
160/* clone */
161clone = unur_gen_clone(gen);
162unur_free(gen);
163gen = clone;
164        -->compare_sequence_gen
165
166/* set smoothing factor */
167unur_free(gen);
168par = unur_vempk_new(distr);
169unur_vempk_set_smoothing( par, 3. );
170gen = unur_init( par );
171        -->compare_sequence_gen_start
172
173/* clone */
174clone = unur_gen_clone(gen);
175unur_free(gen);
176gen = clone;
177        -->compare_sequence_gen
178
179#.....................................................................
180
181#[sample - compare stringparser:
182#   distr = NULL;
183#   par = NULL;
184#   gen = NULL; ]
185#
186# Not implemented yet!
187#
188
189#############################################################################
190
191[validate]
192
193[validate - generators:]
194
195# default
196par[0] = unur_vempk_new(@distr@);
197
198# use variance correction
199par[1] = unur_vempk_new(@distr@);
200unur_vempk_set_varcor(par,TRUE);
201
202
203[validate - distributions:]
204
205# approximate normal distribution
206\#define dim (2)
207{ double *data;
208  UNUR_DISTR *dist_mnormal;
209  UNUR_GEN *gen_mnormal;
210  int i;
211  const int ss = 100000;
212  data = malloc(dim*ss*sizeof(double));
213  dist_mnormal = unur_distr_multinormal(dim,NULL,NULL);
214  gen_mnormal = unur_init(unur_mvstd_new(dist_mnormal));
215  for (i=0;i<ss;i++)
216	unur_sample_vec(gen_mnormal, data+i*dim);
217  unur_free(gen_mnormal);
218  unur_distr_free(dist_mnormal);
219  distr[0] = unur_distr_cvemp_new(dim);
220  unur_distr_cvemp_set_data(distr[0],data,ss);
221  free(data); }
222\#undef dim
223
224# approximate normal distribution
225\#define dim (3)
226{ double *data;
227  UNUR_DISTR *dist_mnormal;
228  UNUR_GEN *gen_mnormal;
229  int i;
230  const int ss = 100000;
231  data = malloc(dim*ss*sizeof(double));
232  dist_mnormal = unur_distr_multinormal(dim,NULL,NULL);
233  gen_mnormal = unur_init(unur_mvstd_new(dist_mnormal));
234  for (i=0;i<ss;i++)
235	unur_sample_vec(gen_mnormal, data+i*dim);
236  unur_free(gen_mnormal);
237  unur_distr_free(dist_mnormal);
238  distr[1] = unur_distr_cvemp_new(dim);
239  unur_distr_cvemp_set_data(distr[1],data,ss);
240  free(data); }
241\#undef dim
242
243
244[validate - test chi2:]
245
246#  + ... pass test
247#  0 ... fail to initialize generator
248#  - ... fail test
249#  . ... do not run test
250#  # ... comment
251#
252# generators:
253#   [0] default
254#   [1] use variance correction
255#
256#	[0]  [1]	# distribution
257#----------------------------------------------------------------
258 <0>	 +    +		# approximate normal distribution (dim=2, sample size 100000)
259 <1>	 +    +		# approximate normal distribution (dim=3, sample size 100000)
260
261
262#############################################################################
263#############################################################################
264
265[verbatim]
266
267#############################################################################
268