# $Id: t_arou.conf 5330 2011-04-19 10:50:18Z leydold $ ############################################################################# [main] [main - data:] # method method: AROU [main - header:] /* prototypes */ double pdf( double x, const UNUR_DISTR *distr ); double pdf_bimodal( double x, const UNUR_DISTR *distr ); double dpdf_bimodal( double x, const UNUR_DISTR *distr ); double pdf_negative( double x, const UNUR_DISTR *distr ); double dpdf_negative( double x, const UNUR_DISTR *distr ); double pdf_partnegative( double x, const UNUR_DISTR *distr ); double dpdf_partnegative( double x, const UNUR_DISTR *distr ); double pdf_sqrtlin( double x, const UNUR_DISTR *distr ); double dpdf_sqrtlin( double x, const UNUR_DISTR *distr ); double cdf_sqrtlin( double x, const UNUR_DISTR *distr ); double pdf_sqrtlinshft(double x, const UNUR_DISTR *distr ); double dpdf_sqrtlinshft( double x, const UNUR_DISTR *distr ); double cdf_sqrtlinshft( double x, const UNUR_DISTR *distr ); \#define COMPARE_SAMPLE_SIZE (10000) \#define VIOLATE_SAMPLE_SIZE (20) /* \#define SEED (298346) */ ############################################################################# [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_cont_new(); ] /* pdf, dpdf */ ~( distr ); --> expected_NULL --> UNUR_ERR_DISTR_REQUIRED /* dpdf */ unur_distr_cont_set_pdf(distr,pdf); ~( distr ); --> expected_NULL --> UNUR_ERR_DISTR_REQUIRED ############################################################################# [set] [set - invalid NULL ptr: par = NULL; ] ~_usedars( par, 1 ); --> expected_setfailed --> UNUR_ERR_NULL ~_darsfactor( par, 1. ); --> expected_setfailed --> UNUR_ERR_NULL ~_cpoints( par, 0, NULL ); --> expected_setfailed --> UNUR_ERR_NULL ~_guidefactor( par, 1. ); --> expected_setfailed --> UNUR_ERR_NULL ~_max_sqhratio( par, 0.95 ); --> expected_setfailed --> UNUR_ERR_NULL ~_max_segments( par, 100 ); --> expected_setfailed --> UNUR_ERR_NULL ~_usecenter( par, 1 ); --> expected_setfailed --> UNUR_ERR_NULL ~_verify( par, 1 ); --> expected_setfailed --> UNUR_ERR_NULL ~_pedantic( par, 1 ); --> expected_setfailed --> UNUR_ERR_NULL [set - invalid parameter object: double fpar[2] = {0.,1.}; distr = unur_distr_normal(fpar,2); par = unur_tdr_new(distr); ] ~_usedars( par, 1 ); --> expected_setfailed --> UNUR_ERR_PAR_INVALID ~_darsfactor( par, 1. ); --> expected_setfailed --> UNUR_ERR_PAR_INVALID ~_cpoints( par, 0, NULL ); --> expected_setfailed --> UNUR_ERR_PAR_INVALID ~_guidefactor( par, 1. ); --> expected_setfailed --> UNUR_ERR_PAR_INVALID ~_max_sqhratio( par, 0.95 ); --> expected_setfailed --> UNUR_ERR_PAR_INVALID ~_max_segments( par, 100 ); --> expected_setfailed --> UNUR_ERR_PAR_INVALID ~_usecenter( par, 1 ); --> expected_setfailed --> UNUR_ERR_PAR_INVALID ~_verify( par, 1 ); --> expected_setfailed --> UNUR_ERR_PAR_INVALID ~_pedantic( par, 1 ); --> expected_setfailed --> UNUR_ERR_PAR_INVALID unur_par_free(par); [set - invalid parameters: double stp[] = {1.,0.,1.}; int n_stp = 3; double fpar[2] = {0.,1.}; distr = unur_distr_normal(fpar,2); par = unur_arou_new(distr); ] ~_darsfactor( par, -1. ); --> expected_setfailed --> UNUR_ERR_PAR_SET ~_cpoints( par, -1, NULL ); --> expected_setfailed --> UNUR_ERR_PAR_SET ~_cpoints( par, n_stp, stp ); --> expected_setfailed --> UNUR_ERR_PAR_SET ~_guidefactor( par, -1. ); --> expected_setfailed --> UNUR_ERR_PAR_SET ~_max_sqhratio( par, -1. ); --> expected_setfailed --> UNUR_ERR_PAR_SET ~_max_sqhratio( par, 2. ); --> expected_setfailed --> UNUR_ERR_PAR_SET ~_max_segments( par, 0 ); --> expected_setfailed --> UNUR_ERR_PAR_SET unur_par_free(par); ############################################################################# [get] [get - invalid generator object: distr = unur_distr_normal(NULL,0); par = unur_tdr_new(distr); gen = unur_init(par); <-- ! NULL ] ~_sqhratio(gen); --> expected_INFINITY --> UNUR_ERR_GEN_INVALID ~_hatarea(gen); --> expected_INFINITY --> UNUR_ERR_GEN_INVALID ~_squeezearea(gen); --> expected_INFINITY --> UNUR_ERR_GEN_INVALID ############################################################################# [chg] [chg - invalid generator object: double fpar[2] = {0.,1.}; distr = unur_distr_normal(fpar,2); par = unur_srou_new(distr); unur_set_debug(par,0); gen = unur_init( par ); <-- ! NULL ] ~_verify(gen,1); --> expected_setfailed --> UNUR_ERR_GEN_INVALID ############################################################################# [init] [init - invalid NULL ptr: par = NULL; ] unur_init( par ); --> expected_NULL --> UNUR_ERR_NULL [init - stp out of domain: double stp[] = {-2.5,-1.,0.,1.,2.5}; int n_stp = 5; gen = NULL; distr = unur_distr_normal(NULL,0); unur_distr_cont_set_domain(distr,-2.,2.); par = unur_arou_new(distr); unur_arou_set_cpoints( par, n_stp, stp ); ] gen = unur_init( par ); --> none --> UNUR_ERR_GEN_DATA [init - bimodal: distr = unur_distr_cont_new(); unur_distr_cont_set_pdf(distr,pdf_bimodal); unur_distr_cont_set_dpdf(distr,dpdf_bimodal); par = unur_arou_new(distr); unur_arou_set_cpoints( par, 30, NULL ); ] unur_init( par ); --> expected_NULL --> UNUR_ERR_GEN_CONDITION [init - negative value of pdf: distr = unur_distr_cont_new(); unur_distr_cont_set_pdf(distr,pdf_negative); unur_distr_cont_set_dpdf(distr,dpdf_negative); par = NULL; ] par = unur_arou_new(distr); unur_arou_set_cpoints( par, 30, NULL ); unur_init( par ); --> expected_NULL --> UNUR_ERR_GEN_CONDITION unur_distr_cont_set_domain(distr,-2.,2.); par = unur_arou_new(distr); unur_arou_set_cpoints( par, 30, NULL ); unur_init( par ); --> expected_NULL --> UNUR_ERR_GEN_DATA ############################################################################# [reinit] [reinit - does not exist: distr = unur_distr_normal(NULL,0); par = unur_arou_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 - partial negative value of pdf: int i; double x; double stp[] = {-0.9,0.9}; int n_stp = 2; distr = unur_distr_cont_new(); unur_distr_cont_set_pdf(distr,pdf_partnegative); unur_distr_cont_set_dpdf(distr,dpdf_partnegative); par = unur_arou_new(distr); unur_arou_set_usedars(par,FALSE); unur_arou_set_cpoints( par, n_stp, stp ); unur_arou_set_pedantic( par, 1 ); gen = unur_init( par ); <-- ! NULL ] for (i=0; i<100; i++) { x = unur_sample_cont(gen); } x; --> expected_INFINITY --> UNUR_ERR_GEN_CONDITION #..................................................................... [sample - compare clone: UNUR_GEN *clone; distr = unur_distr_normal(NULL,0); par = NULL; gen = NULL; ] /* original generator object */ par = unur_arou_new(distr); unur_arou_set_max_sqhratio(par,0.); gen = unur_init(par); -->compare_sequence_gen_start /* clone */ clone = unur_gen_clone(gen); unur_free(gen); gen = clone; -->compare_sequence_gen # due to optimizations of the compiler the following test # fails for some compilers with some options (!?) # #[sample - compare: # distr = unur_distr_normal(NULL,0); # par = NULL; ] # #/* default algorithm */ #par = unur_arou_new(distr); # -->compare_sequence_par_start # #/* verifying mode */ #par = unur_arou_new(distr); #unur_arou_set_verify(par,1); # -->compare_sequence_par #..................................................................... [sample - compare stringparser: double fpar[10]; distr = NULL; par = NULL; gen = NULL; ] distr = unur_distr_normal(NULL,0); par = unur_arou_new(distr); gen = unur_init(par); -->compare_sequence_gen_start unur_free(gen); gen = NULL; unur_distr_free(distr); distr = NULL; gen = unur_str2gen( "normal & method = arou" ); -->compare_sequence_gen unur_free(gen); gen = NULL; gen = unur_str2gen( "normal() & method = arou" ); -->compare_sequence_gen unur_free(gen); gen = NULL; gen = unur_str2gen( "normal(0.,1.) & method = arou" ); -->compare_sequence_gen unur_free(gen); gen = NULL; gen = unur_str2gen( "normal(0,1) & method = arou" ); -->compare_sequence_gen unur_free(gen); gen = NULL; gen = unur_str2gen( "distr = normal(0,1) & method = arou" ); -->compare_sequence_gen unur_free(gen); gen = NULL; fpar[0] = 1.; fpar[1] = 2.; distr = unur_distr_normal(fpar,2); par = unur_arou_new(distr); unur_arou_set_usedars(par,1); gen = unur_init(par); -->compare_sequence_gen_start unur_free(gen); gen = NULL; unur_distr_free(distr); distr = NULL; gen = unur_str2gen( "normal(1,2) & method = arou; usedars" ); -->compare_sequence_gen unur_free(gen); gen = NULL; fpar[0] = 1.; fpar[1] = 2.; distr = unur_distr_normal(fpar,2); par = unur_arou_new(distr); unur_arou_set_usedars(par,1); unur_arou_set_darsfactor(par,0.1); gen = unur_init(par); -->compare_sequence_gen_start unur_free(gen); gen = NULL; unur_distr_free(distr); distr = NULL; gen = unur_str2gen( "normal(1,2) & method = arou; usedars; darsfactor=0.1" ); -->compare_sequence_gen unur_free(gen); gen = NULL; fpar[0] = 1.; fpar[1] = 2.; distr = unur_distr_normal(fpar,2); unur_distr_cont_set_domain(distr,0.,2.); par = unur_arou_new(distr); gen = unur_init(par); -->compare_sequence_gen_start unur_free(gen); gen = NULL; unur_distr_free(distr); distr = NULL; gen = unur_str2gen( "normal(1,2); domain = 0, 2 & method = arou" ); -->compare_sequence_gen unur_free(gen); gen = NULL; gen = unur_str2gen( "normal(1,2); domain = (0,2) & method = arou" ); -->compare_sequence_gen unur_free(gen); gen = NULL; distr = unur_distr_normal(NULL,0); par = unur_arou_new(distr); fpar[0] = -2; fpar[1] = -1.5; fpar[2] = -1; fpar[3] = -0.5; fpar[4] = 0; fpar[5] = 0.5; fpar[6] = 1; fpar[7] = 1.5; fpar[8] = 2; unur_arou_set_cpoints(par,9,fpar); gen = unur_init(par); -->compare_sequence_gen_start unur_free(gen); gen = NULL; unur_distr_free(distr); distr = NULL; gen = unur_str2gen( "normal() & \ method = arou; cpoints = (-2,-1.5,-1,-0.5,0,0.5,1,1.5,2)" ); -->compare_sequence_gen unur_free(gen); gen = NULL; distr = unur_distr_normal(NULL,0); unur_distr_cont_set_center(distr,0.); par = unur_arou_new(distr); unur_arou_set_cpoints(par,20,NULL); unur_arou_set_guidefactor(par,1.); unur_arou_set_max_segments(par,40); unur_arou_set_max_sqhratio(par,0.5); unur_arou_set_pedantic(par,FALSE); unur_arou_set_usecenter(par,TRUE); unur_arou_set_verify(par,TRUE); gen = unur_init(par); -->compare_sequence_gen_start unur_free(gen); gen = NULL; unur_distr_free(distr); distr = NULL; gen = unur_str2gen( "normal(); center=0. & \ method = arou; \ cpoints = 20; guidefactor = 1.; max_segments = 40; \ max_sqhratio = 0.5; pedantic = off; usecenter = true; verify = on" ); -->compare_sequence_gen ############################################################################# [validate] [validate - generators:] # default program (without DARS) par[0] = unur_arou_new(@distr@); unur_arou_set_usedars(par,0); # use dars par[1] = unur_arou_new(@distr@); unur_arou_set_cpoints( par, 8, NULL ); unur_arou_set_usedars(par,1); # small squeeze / hat ratio par[2] = unur_arou_new(@distr@); unur_arou_set_cpoints( par, 8, NULL ); unur_arou_set_max_sqhratio(par,0.5); [validate - distributions:] # Beta distributions fpm[0] = 1.; fpm[1] = 2.; distr[0] = unur_distr_beta(fpm,2); fpm[0] = 2.; fpm[1] = 1.; distr[32] = unur_distr_beta(fpm,2); fpm[0] = 1.; fpm[1] = 5.; distr[1] = unur_distr_beta(fpm,2); fpm[0] = 1.; fpm[1] = 100.; distr[2] = unur_distr_beta(fpm,2); fpm[0] = 2.; fpm[1] = 5.; distr[30] = unur_distr_beta(fpm,2); fpm[0] = 5.; fpm[1] = 2.; distr[31] = unur_distr_beta(fpm,2); fpm[0] = 3.; fpm[1] = 4.; distr[3] = unur_distr_beta(fpm,2); fpm[0] = 5.; fpm[1] = 100.; distr[4] = unur_distr_beta(fpm,2); fpm[0] = 500.; fpm[1] = 300.; distr[5] = unur_distr_beta(fpm,2); fpm[0] = 5.; fpm[1] = 10.; fpm[2] = -3.; fpm[3] = 15.; distr[6] = unur_distr_beta(fpm,4); # Cauchy distributions distr[7] = unur_distr_cauchy(NULL,0); fpm[0] = 1.; fpm[1] = 20.; distr[8] = unur_distr_cauchy(fpm,2); # Exponential distributions distr[24] = unur_distr_exponential(NULL,0); fpm[0] = 30.; fpm[1] = -5.; distr[25] = unur_distr_exponential(fpm,2); # Gamma distributions fpm[0] = 1.; distr[9] = unur_distr_gamma(fpm,1); fpm[0] = 2.; distr[10] = unur_distr_gamma(fpm,1); fpm[0] = 3.; distr[11] = unur_distr_gamma(fpm,1); fpm[0] = 10.; distr[12] = unur_distr_gamma(fpm,1); fpm[0] = 1000.; distr[13] = unur_distr_gamma(fpm,1); fpm[0] = 5.; fpm[1] = 1000.; distr[14] = unur_distr_gamma(fpm,2); fpm[0] = 5.; fpm[1] = 1.e-5; distr[15] = unur_distr_gamma(fpm,2); fpm[0] = 5.; fpm[1] = 10.; fpm[2] = 1000; distr[16] = unur_distr_gamma(fpm,3); # Laplace distributions distr[26] = unur_distr_laplace(NULL,0); fpm[0] = -10.; fpm[1] = 100.; distr[27] = unur_distr_laplace(fpm,2); # Normal distributions distr[17] = unur_distr_normal(NULL,0); fpm[0] = 1.; fpm[1] = 1.e-5; distr[18] = unur_distr_normal(fpm,2); fpm[0] = 0.; fpm[1] = 1.e+5; distr[19] = unur_distr_normal(fpm,2); # Uniform distributions distr[20] = unur_distr_uniform(NULL,0); fpm[0] = 1.; fpm[1] = 20.; distr[21] = unur_distr_uniform(fpm,2); # pdf with piecewise linear function as transformed density with T = -1/sqrt distr[28] = unur_distr_cont_new(); unur_distr_cont_set_pdf(distr[28],pdf_sqrtlin); unur_distr_cont_set_dpdf(distr[28],dpdf_sqrtlin); unur_distr_cont_set_cdf(distr[28],cdf_sqrtlin); unur_distr_set_name(distr[28],"sqrtlin"); # pdf with piecewise linear function as transformed density with T = -1/sqrt and shifted mode distr[29] = unur_distr_cont_new(); unur_distr_cont_set_pdf(distr[29],pdf_sqrtlinshft); unur_distr_cont_set_dpdf(distr[29],dpdf_sqrtlinshft); unur_distr_cont_set_cdf(distr[29],cdf_sqrtlinshft); unur_distr_set_name(distr[29],"sqrtlin"); # truncated distributions distr[22] = unur_distr_cauchy(NULL,0); unur_distr_cont_set_domain(distr[22],0.1,1.); unur_distr_cont_upd_mode(distr[22]); unur_distr_cont_upd_pdfarea(distr[22]); # domain exceeds support of pdf fpm[0] = 3.; fpm[1] = 4.; distr[23] = unur_distr_beta(fpm,2); unur_distr_cont_set_domain(distr[23],-2.,5.); # number of distributions: 33 [validate - test chi2:] # + ... pass test # 0 ... fail to initialize generator # - ... fail test # . ... do not run test # # ... comment # # generators: # [0] without DARS # [1] with DARS # [2] small squeeze / hat ratio # #gen [0] [1] [2] # distribution #--------------------------------------------- <0> + + + # beta (1, 2) <32> + + + # beta (2, 1) <1> + + + # beta (1, 5) x <2> + + + # beta (1, 100) <30> + + + # beta (2, 5) <31> + + + # beta (5, 2) <3> + + + # beta (3, 4) x <4> + + + # beta (5, 100) x <5> + + + # beta (500, 300) <6> + + + # beta (5, 10, -3, 15) <24> + + + # exponential () x<25> + + + # exponential (30, -5) <7> + + + # cauchy () x <8> + + + # cauchy (1, 20) <9> + + + # gamma (1) <10> + + + # gamma (2) <11> + + + # gamma (3) <12> + + + # gamma (10) x<13> + + + # gamma (1000) <14> + + + # gamma (5, 1000, 0) x<15> + + + # gamma (5, 1e-05, 0) x<16> + + + # gamma (5, 10, 100000) <26> + + + # laplace () <27> + + + # laplace (-10, 100) <17> + + + # normal () x<18> + + . # normal (1, 1e-05) <19> + + + # normal (1, 1e+05) <20> + + + # uniform () <21> + + + # uniform (1, 20) <22> + + + # cauchy () - truncated <23> + + + # beta () - domain superset of support #<28> + + + # pdf with piecewise linear function as transformed density with T = -1/sqrt #<29> . . . # [28] with shifted mode [validate - verify hat:] # + ... pass test # ~ ... fail in at most 1% of samples # 0 ... fail to initialize generator # - ... fail test # . ... do not run test # # ... comment # # generators: # [0] without DARS # [1] with DARS # [2] small squeeze / hat ratio # #gen [0] [1] [2] # distribution #--------------------------------------------- <0> + + + # beta (1, 2) <32> + + + # beta (2, 1) <1> + + + # beta (1, 5) x <2> + + + # beta (1, 100) <30> + + + # beta (2, 5) <31> + + + # beta (5, 2) <3> + + + # beta (3, 4) x <4> + + + # beta (5, 100) x <5> + + + # beta (500, 300) <6> + + + # beta (5, 10, -3, 15) <24> + + + # exponential () x<25> + + + # exponential (30, -5) <7> + + + # cauchy () <8> + + + # cauchy (1, 20) <9> + + + # gamma (1) <10> + + + # gamma (2) <11> + + + # gamma (3) <12> + + + # gamma (10) x<13> + + + # gamma (1000) <14> + + + # gamma (5, 1000, 0) x<15> + + + # gamma (5, 1e-05, 0) x<16> + + + # gamma (5, 10, 100000) <26> + + + # laplace () <27> + + + # laplace (-10, 100) <17> + + + # normal () x<18> + + + # normal (1, 1e-05) <19> + + + # normal (1, 1e+05) <20> + + + # uniform () <21> + + + # uniform (1, 20) <22> + + + # cauchy () - truncated <23> + + + # beta () - domain superset of support #<28> + + + # pdf with piecewise linear function as transformed density with T = -1/sqrt #<29> . . . # [28] with shifted mode ############################################################################# ############################################################################# [verbatim] /* pdf of bimodal density */ double pdf_bimodal( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return ( exp(-(x-1.)*(x-1.)) + exp(-(x+1.)*(x+1.)) ); } double dpdf_bimodal( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return ( -2. * (x-1.) * exp(-(x-1.)*(x-1.)) -2. * (x+1.) * exp(-(x+1.)*(x+1.)) ); } /* pdf with negative value */ double pdf_negative( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return (-x*x); } double dpdf_negative( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return (-2.*x); } /* pdf with partial negative value */ double pdf_partnegative( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return ((x>-0.89 && x<0.89) ? -1.: exp(-x*x)); } double dpdf_partnegative( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return ((x>-0.89 && x<0.89) ?0.: -2.*x*exp(-x*x)); } /* pdf of normal density */ double pdf( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { return exp(-x*x/2.); } /* end of pdf */ /* pdf with piecewise linear function as transformed density with T = -1/sqrt */ double pdf_sqrtlin( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { double y = 1./(fabs(x)+1.); return y*y; } double dpdf_sqrtlin( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { double y = 1./(fabs(x)+1.); y = 2.*y*y*y; return ((x<0.) ? y : - y); } double cdf_sqrtlin( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { if (x<=0.) return 0.5/(1.-x); else return (1.-0.5/(1.+x)); } /* pdf with piecewise linear function as transformed density with T = -1/sqrt and shifted mode */ double pdf_sqrtlinshft( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { double y; x -= 1.; y = 1./(fabs(x)+1.); return y*y; } double dpdf_sqrtlinshft( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { double y; x -= 1.; y = 1./(fabs(x)+1.); y = 2.*y*y*y; return ((x<0.) ? y : - y); } double cdf_sqrtlinshft( double x, const UNUR_DISTR *distr ATTRIBUTE__UNUSED) { x -= 1.; if (x<=0.) return 0.5/(1.-x); else return (1.-0.5/(1.+x)); } #############################################################################