1# $Id: t_distr_discr.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: DISTR_DISCR 10 11[main - header:] 12 13## we need UNUR_DISTR_MAXPARAMS for a test: 14\#include<unuran_config.h> 15 16/* prototypes */ 17 18\#define COMPARE_SAMPLE_SIZE (500) 19\#define VIOLATE_SAMPLE_SIZE (20) 20 21double pmf(int k, const UNUR_DISTR *distr); 22double icdf(int k, const UNUR_DISTR *distr); 23int invcdf(double x, const UNUR_DISTR *distr); 24 25############################################################################# 26 27[new] 28 29############################################################################# 30 31[set] 32 33[set - invalid NULL ptr: 34 distr = NULL; ] 35 36unur_distr_discr_set_pv( distr, NULL, 0 ); 37 --> expected_setfailed --> UNUR_ERR_NULL 38 39unur_distr_discr_set_pmf( distr, pmf ); 40 --> expected_setfailed --> UNUR_ERR_NULL 41 42unur_distr_discr_set_cdf( distr, icdf ); 43 --> expected_setfailed --> UNUR_ERR_NULL 44 45unur_distr_discr_set_invcdf( distr, invcdf ); 46 --> expected_setfailed --> UNUR_ERR_NULL 47 48unur_distr_discr_set_pmfstr( distr, "pmf" ); 49 --> expected_setfailed --> UNUR_ERR_NULL 50 51unur_distr_discr_set_cdfstr( distr, "cdf" ); 52 --> expected_setfailed --> UNUR_ERR_NULL 53 54unur_distr_discr_set_pmfparams( distr, NULL, 0 ); 55 --> expected_setfailed --> UNUR_ERR_NULL 56 57unur_distr_discr_set_domain( distr, 0, 10 ); 58 --> expected_setfailed --> UNUR_ERR_NULL 59 60unur_distr_discr_set_mode( distr, 0 ); 61 --> expected_setfailed --> UNUR_ERR_NULL 62 63unur_distr_discr_set_pmfsum( distr, 1. ); 64 --> expected_setfailed --> UNUR_ERR_NULL 65 66 67[set - invalid distribution type: 68 distr = unur_distr_cont_new(); ] 69 70unur_distr_discr_set_pv( distr, NULL, 0 ); 71 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 72 73unur_distr_discr_set_pmf( distr, pmf ); 74 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 75 76unur_distr_discr_set_cdf( distr, icdf ); 77 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 78 79unur_distr_discr_set_invcdf( distr, invcdf ); 80 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 81 82unur_distr_discr_set_pmfstr( distr, "exp(-k)" ); 83 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 84 85unur_distr_discr_set_cdfstr( distr, "exp(-k)" ); 86 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 87 88unur_distr_discr_set_pmfparams( distr, NULL, 0 ); 89 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 90 91unur_distr_discr_set_domain( distr, 0, 10 ); 92 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 93 94unur_distr_discr_set_mode( distr, 0 ); 95 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 96 97unur_distr_discr_set_pmfsum( distr, 1. ); 98 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 99 100 101[set - invalid NULL ptr: 102 distr = unur_distr_discr_new(); ] 103 104unur_distr_discr_set_pmf( distr, NULL ); 105 --> expected_setfailed --> UNUR_ERR_NULL 106 107unur_distr_discr_set_cdf( distr, NULL ); 108 --> expected_setfailed --> UNUR_ERR_NULL 109 110unur_distr_discr_set_invcdf( distr, NULL ); 111 --> expected_setfailed --> UNUR_ERR_NULL 112 113unur_distr_discr_set_pmfstr( distr, NULL ); 114 --> expected_setfailed --> UNUR_ERR_NULL 115 116unur_distr_discr_set_cdfstr( distr, NULL ); 117 --> expected_setfailed --> UNUR_ERR_NULL 118 119unur_distr_discr_set_pmfparams( distr, NULL, 1 ); 120 --> expected_setfailed --> UNUR_ERR_NULL 121 122 123[set - invalid parameters: 124 double pv[] = {1.,2.,3.}; 125 distr = unur_distr_discr_new(); ] 126 127unur_distr_discr_set_pmfstr( distr, "" ); 128 --> expected_setfailed --> UNUR_ERR_DISTR_SET 129 130unur_distr_discr_set_pmfstr( distr, "beta(2.)" ); 131 --> expected_setfailed --> UNUR_ERR_DISTR_SET 132 133unur_distr_discr_set_cdfstr( distr, "" ); 134 --> expected_setfailed --> UNUR_ERR_DISTR_SET 135 136unur_distr_discr_set_cdfstr( distr, "beta(2.)" ); 137 --> expected_setfailed --> UNUR_ERR_DISTR_SET 138 139unur_distr_discr_set_pmfparams( distr, pv, -1 ); 140 --> expected_setfailed --> UNUR_ERR_DISTR_NPARAMS 141 142unur_distr_discr_set_pmfparams( distr, pv, UNUR_DISTR_MAXPARAMS +1 ); 143 --> expected_setfailed --> UNUR_ERR_DISTR_NPARAMS 144 145unur_distr_discr_set_domain( distr, 10, 1 ); 146 --> expected_setfailed --> UNUR_ERR_DISTR_SET 147 148unur_distr_discr_set_pmfsum( distr, -1. ); 149 --> expected_setfailed --> UNUR_ERR_DISTR_SET 150 151 152############################################################################# 153 154[get] 155 156[get - invalid NULL ptr: 157 distr = NULL; ] 158 159unur_distr_discr_get_pv( distr, NULL ); 160 --> expected_zero --> UNUR_ERR_NULL 161 162unur_distr_discr_get_pmf( distr ); 163 --> expected_NULL --> UNUR_ERR_NULL 164 165unur_distr_discr_get_cdf( distr ); 166 --> expected_NULL --> UNUR_ERR_NULL 167 168unur_distr_discr_get_invcdf( distr ); 169 --> expected_NULL --> UNUR_ERR_NULL 170 171unur_distr_discr_get_pmfstr( distr ); 172 --> expected_NULL --> UNUR_ERR_NULL 173 174unur_distr_discr_get_cdfstr( distr ); 175 --> expected_NULL --> UNUR_ERR_NULL 176 177unur_distr_discr_get_pmfparams( distr, NULL ); 178 --> expected_zero --> UNUR_ERR_NULL 179 180unur_distr_discr_get_pmfsum( distr ); 181 --> expected_INFINITY --> UNUR_ERR_NULL 182 183unur_distr_discr_make_pv( distr ); 184 --> expected_zero --> UNUR_ERR_NULL 185 186 187[get - invalid distribution type: 188 int ia, ib; 189 distr = unur_distr_cont_new(); ] 190 191unur_distr_discr_get_pmf( distr ); 192 --> expected_NULL --> UNUR_ERR_DISTR_INVALID 193 194unur_distr_discr_get_cdf( distr ); 195 --> expected_NULL --> UNUR_ERR_DISTR_INVALID 196 197unur_distr_discr_get_invcdf( distr ); 198 --> expected_NULL --> UNUR_ERR_DISTR_INVALID 199 200unur_distr_discr_get_pmfstr( distr ); 201 --> expected_NULL --> UNUR_ERR_DISTR_INVALID 202 203unur_distr_discr_get_cdfstr( distr ); 204 --> expected_NULL --> UNUR_ERR_DISTR_INVALID 205 206unur_distr_discr_get_pv( distr, NULL ); 207 --> expected_zero --> UNUR_ERR_DISTR_INVALID 208 209unur_distr_discr_get_domain( distr, &ia, &ib ); 210 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 211 212unur_distr_discr_get_pmfparams( distr, NULL ); 213 --> expected_zero --> UNUR_ERR_DISTR_INVALID 214 215unur_distr_discr_get_pmfsum( distr ); 216 --> expected_INFINITY --> UNUR_ERR_DISTR_INVALID 217 218unur_distr_discr_make_pv( distr ); 219 --> expected_zero --> UNUR_ERR_DISTR_INVALID 220 221 222[get - parameters not unknown: 223 distr = unur_distr_discr_new(); ] 224 225unur_distr_discr_get_pmfstr( distr ); 226 --> expected_NULL --> UNUR_ERR_NULL 227 228unur_distr_discr_get_cdfstr( distr ); 229 --> expected_NULL --> UNUR_ERR_NULL 230 231unur_distr_discr_get_pmfsum( distr ); 232 --> expected_INFINITY --> UNUR_ERR_DISTR_GET 233 234unur_distr_discr_get_mode( distr ); 235 --> expected_INTMAX --> UNUR_ERR_DISTR_GET 236 237unur_distr_discr_make_pv( distr ); 238 --> expected_zero --> UNUR_ERR_DISTR_GET 239 240 241############################################################################# 242 243[chg] 244 245[chg - invalid NULL ptr: 246 distr = NULL; ] 247 248unur_distr_discr_upd_mode( distr ); 249 --> expected_setfailed --> UNUR_ERR_NULL 250 251unur_distr_discr_upd_pmfsum( distr ); 252 --> expected_setfailed --> UNUR_ERR_NULL 253 254 255[chg - invalid distribution type: 256 distr = unur_distr_cont_new(); ] 257 258unur_distr_discr_upd_mode( distr ); 259 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 260 261unur_distr_discr_upd_pmfsum( distr ); 262 --> expected_setfailed --> UNUR_ERR_DISTR_INVALID 263 264 265[chg - missing data: 266 distr = unur_distr_discr_new(); ] 267 268unur_distr_discr_upd_mode( distr ); 269 --> expected_setfailed --> UNUR_ERR_DISTR_DATA 270 271unur_distr_discr_upd_pmfsum( distr ); 272 --> expected_setfailed --> UNUR_ERR_DISTR_DATA 273 274 275############################################################################## 276 277# [init] 278 279############################################################################# 280 281# [reinit] 282 283############################################################################# 284 285[sample] 286 287[sample - invalid NULL ptr: 288 distr = NULL; ] 289 290unur_distr_discr_eval_pmf( 1, distr ); 291 --> expected_INFINITY --> UNUR_ERR_NULL 292 293unur_distr_discr_eval_cdf( 1, distr ); 294 --> expected_INFINITY --> UNUR_ERR_NULL 295 296unur_distr_discr_eval_invcdf( 0.5, distr ); 297 --> expected_INTMAX --> UNUR_ERR_NULL 298 299#..................................................................... 300 301[sample - invalid distribution object: 302 distr = unur_distr_cont_new(); ] 303 304unur_distr_discr_eval_pmf( 1, distr ); 305 --> expected_INFINITY --> UNUR_ERR_DISTR_INVALID 306 307unur_distr_discr_eval_cdf( 1, distr ); 308 --> expected_INFINITY --> UNUR_ERR_DISTR_INVALID 309 310unur_distr_discr_eval_invcdf( 0.5, distr ); 311 --> expected_INTMAX --> UNUR_ERR_DISTR_INVALID 312 313#..................................................................... 314 315[sample - missing data: 316 distr = unur_distr_discr_new(); ] 317 318unur_distr_discr_eval_pmf( 1, distr ); 319 --> expected_INFINITY --> UNUR_ERR_DISTR_DATA 320 321unur_distr_discr_eval_cdf( 1, distr ); 322 --> expected_INFINITY --> UNUR_ERR_DISTR_DATA 323 324unur_distr_discr_eval_invcdf( 0.5, distr ); 325 --> expected_INTMAX --> UNUR_ERR_DISTR_DATA 326 327 328############################################################################# 329 330# [validate] 331 332############################################################################# 333############################################################################# 334 335[verbatim] 336 337double pmf(int k ATTRIBUTE__UNUSED, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return 1.; } 338double icdf(int k ATTRIBUTE__UNUSED, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return 1.; } 339int invcdf(double x ATTRIBUTE__UNUSED, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return 1; } 340 341############################################################################# 342