jtc_exp.cc - Methods file for Experiments for "Beads-in-a-Jar"



// methods for jtc_exp.h, experiments that relate to Beads-in-a-Jar // systems. /* Some default val. in C quotes */ #include "jtc_exp.h" const char *const Garety91dat::ERROR=" >>---> Garety91dat error : " ; const char *const RBWelcomeDat::ERROR=" >>---> RBWelcomeDat error : " ; const char *const Beads_Exp_I::ERROR=" >>---> Beads_Exp_I error : " ; // -------------------------------------------------------------------------- /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ /* B.a. Summary data from Fear & Healy 1997 */ FearHealy97dat::FearHealy97dat() : Cond1Tab2() { Cond1Tab2.resize(Range(1,6), Range(1,4)) ; Cond1Tab2 = // NB Row 3 is the 'JTC' one. // Control OCD DD Mixed 0.54, 0.53, 0.51, 0.52, // Init. Certainty 0.10, 0.18, 0.06, 0.17, // " " SD 2.6, 3.4, 1.5, 2.7, // Draws to decision 1.3, 2.5, 0.9, 1.8, // " " SD 0.967, 0.923, 0.773, 0.933, // participant fraction deci- // ding on 85%-black jar, A. 30, 26, 22, 15 ; // and N per group. } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FearHealy97dat::~FearHealy97dat() { } /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ /* B.b. from Garety_et_al_91 */ Garety91dat::Garety91dat() { int i ; // auxiliaries gLab =1; bLab=-1; // the labels. gseq = vector(1,20); // deliberately prehistoric 'vectors' bseq = vector(1,20); // " ng_gseq = vector(0, 20) ; // NOTE THESE HAVE ZERO INDEX TOO, FOR 0 DRAWS. ng_bseq = vector(0, 20) ; for (i=1; i<=20; i++) { gseq[i]=0.0 ; bseq[i]=1.0 ; } // now set the really g ones in gseq, so that it is 1110111101 0001000010 : gseq[1]=gseq[2]=gseq[3]=gseq[5]=gseq[6]=gseq[7]=gseq[8]=gseq[10]=gseq[14]=gseq[19]=1.0 ; // and now all the really b ones in bseq, so that it is 0001000010 1110111101 : bseq[1]=bseq[2]=bseq[3]=bseq[5]=bseq[6]=bseq[7]=bseq[8]=bseq[10]=bseq[14]=bseq[19]=0.0 ; // Now set up number-of-green/good as fn. of no. sampled : ng_gseq[0] = ng_bseq[0] = 0.0 ; for (i=1; i<=20; i++) { ng_gseq[i] = ng_gseq[i-1] + gseq[i] ; ng_bseq[i] = ng_bseq[i-1] + bseq[i] ; } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Garety91dat::~Garety91dat() { free_vector(gseq,1,20); free_vector(bseq,1,20); free_vector(ng_gseq,0,20); free_vector(ng_bseq,0,20); } /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ /* B.b. from Bentall_et_al_06 ('Welcome study'- - The Phenomenology and Cognitive Structure...) */ RBWelcomeDat::RBWelcomeDat() { int i; gLab =1; bLab=-1; // the labels. seq1 = vector(1,20); seq2 = vector(1,20); seq3 = vector(1,20); mes1 = vector(1,20); mes2 = vector(1,20); mes3 = vector(1,20); ng_seq1 = vector(0, 20) ; // For Wellcome running totals ng_seq2 = vector(0, 20) ; // NOTE THESE HAVE ZERO INDEX TOO, FOR 0 DRAWS. ng_seq3 = vector(0, 20) ; // ng_mes1 = vector(0, 20) ; // For Makintosh - El-Deredy running totals ng_mes2 = vector(0, 20) ; // ng_mes3 = vector(0, 20) ; // for (i=1; i<=20; i++) { // start by setting all to black/blue/bad: seq1[i]=seq2[i]=seq3[i]=mes1[i]=mes2[i]=mes3[i]=0.0 ; } // Set the Wellcome study ones: // ... set the really g (Yellow) ones in seq1, so that it is 0100001 ... seq1[2]=seq1[7]=seq1[11]=seq1[13]=seq1[14]=seq1[15]=seq1[16]=seq1[18]=seq1[19]=seq1[20]=1.0 ; // and now all the really g (Yellow) ones in seq2, so that it is 01000100 ... : seq2[2]=seq2[6]=seq2[9]=seq2[11]=seq2[16]=seq2[17]=seq2[20]=1.0 ; // now all the really g (Yellow) ones in seq3, so that it is 10111101 ... seq3[1]=seq3[3]=seq3[4]=seq3[5]=seq3[6]=seq3[8]=seq3[9]=seq3[10]=seq3[12]=seq3[17]=1.0 ; // now pointer array that points to them all. Done for base class / 'historical' reasons : seq = new float* [4]; seq[1]=seq1; seq[2]=seq2; seq[3]=seq3; // Set the Makintosh - El-Deredy Red ones: mes1[2]=mes1[6]=mes1[9]=mes1[11]=mes1[16]=mes1[17]=mes1[20]=1.0 ; mes2[1]=mes2[3]=mes2[4]=mes2[5]=mes2[6]=mes2[8]=mes2[9]=mes2[10]=mes2[12]=mes2[17]=1.0 ; mes3[3]=mes3[6]=mes3[8]=mes3[9]=mes3[11]=mes3[16]=mes3[17]=mes3[20]=1.0 ; MEseq = new float* [4]; MEseq[1]=mes1; MEseq[2]=mes2; MEseq[3]=mes3; // Now set up number-of-yellow/good/red as fn. of no. sampled : ng_seq1[0] = ng_seq2[0] = ng_seq3[0] =ng_mes1[0] = ng_mes2[0] = ng_mes3[0] = 0.0 ; for (i=1; i<=20; i++) { ng_seq1[i] = ng_seq1[i-1] + seq1[i] ; ng_mes1[i] = ng_mes1[i-1] + mes1[i] ; ng_seq2[i] = ng_seq2[i-1] + seq2[i] ; ng_mes2[i] = ng_mes2[i-1] + mes2[i] ; ng_seq3[i] = ng_seq3[i-1] + seq3[i] ; ng_mes3[i] = ng_mes3[i-1] + mes3[i] ; } // and the pointer arrays to manage them: ng_tot = new float* [4]; ng_tot[1]=ng_seq1; ng_tot[2]=ng_seq2; ng_tot[3]=ng_seq3; ng_met = new float* [4]; ng_met[1]=ng_mes1; ng_met[2]=ng_mes2; ng_met[3]=ng_mes3; WJTC.resize(Range(1,229), Range(1,15)) ; // This is a 229 cases x 15 data-columns array. Commas at the beginning of new lines, // not the end of old ones, as added automatically. bij1 is Beads Trial 1, dud1 is Words trial 1 etc. // // group variable values: // 1 Paranoid 1 to 36, I think ! // 2 Remitted Paran. // 3 Never Paran. // 4 Control 66 to 98, I think ! // 5 Late onset SLP // 6 Depr. w. delusions (younger) // 7 Depression (younger) // 8 Older Adult Depression // 9 Older Adult Control // // sex values: // 1 male // 2 female // // diag. group. // 0 N/A // 1 SZ // 2 schizoaffective // 3 Delusional D // 4 depression // 5 depr. w. psychotic features // 6 psychotic depression // 7 vlosp // // group bij1 bij2 bij3 dud1 dud2 dud3 p sex age yrsed origin dur diag ageofo WJTC = 1, 1, 4, 6, 6, 6, 6, 1001.01, 2, 38, 18, 2, 5, 1, 15 , 1, 2, 3, 3, 3, 4, 2, 1002.01, 2, 47, 10, 1, 15, 1, 17 , 1, 1, 2, 2, 13, 12, 7, 1003.01, 2, 23, 12, 5, 8, 1, 21 , 1, 2, 20, 20, 7, 6, 5, 1004.01, 2, 26, 10, 1, 20, 1, 24 , 1, 2, 7, 7, 3, 5, 3, 1005.01, 2, 43, 11, 1, 13, 1, 20 , 1, 2, 2, 2, 5, 4, 2, 1006.01, 2, 34, 11, 2, 57, 1, 30 , 1, 5, 5, 3, 6, 11, 5, 1007.01, 1, 32, 10, 1, 20, 1, 27 , 1, 6, 6, 6, 3, 1, 1, 1008.01, 2, 38, 10, 2, 18, 1, 15 , 1, 3, 3, 2, 3, 3, 3, 1009.01, 2, 20, 12, 1, 7, 1, 17 , 1, 3, 4, 3, 3, 5, 3, 1011.01, 2, 31, 10, 1, 8, 2, 17 , 1, 4, 10, 4, 4, 10, 4, 1012.01, 2, 43, 23, 1, 22, 1, 39 , 1, 3, 3, 3, 3, 3, 3, 1013.01, 1, 32, 12, 1, 3, 1, 32 , 1, 2, 1, 1, 1, 1, 1, 1014.01, 1, 28, 11, 1, 4, 1, 20 , 1, 2, 3, 3, 3, 2, 3, 1015.01, 1, 36, 12, 1, 4, 1, 18 , 1, 9, 7, 7, 8, 6, 5, 3001.01, 1, 28, 16, 5, 43, 1, 26 , 1, 1, 1, 1, 1, 1, 1, 3003.01, 1, 39, 12, 6, 28, 1, 34 , 1, 3, 5, 3, 3, 3, 4, 3004.01, 1, 28, 11, 16, 20, 1, 25 , 1, 2, 2, 3, 3, 3, 3, 3005.01, 1, 37, 11, 4, 4, 1, 27 , 1, 1, 1, 1, 1, 1, 1, 3007.01, 1, 46, 14, 4, 28, 1, 9999 , 1, 6, 14, 6, 2, 5, 3, 4001.01, 1, 25, 13, 1, 30, 1, 25 , 1, 3, 2, 1, 2, 2, 2, 4002.01, 1, 36, 19, 2, 80, 1, 32 , 1, 2, 3, 1, 2, 2, 3, 4003.01, 1, 36, 9, 1, 4, 1, 28 , 1, 3, 2, 3, 3, 3, 3, 4004.01, 1, 22, 10, 1, 44, 1, 19 , 1, 1, 2, 1, 2, 4, 1, 7001.01, 1, 34, 15, 1, 5, 2, 17 , 1, 1, 1, 1, 1, 1, 3, 7002.01, 1, 31, 11, 15, 8, 1, 23 , 1, 1, 1, 1, 1, 1, 1, 7003.01, 2, 34, 11, 1, 16, 1, 27 , 1, 1, 2, 1, 1, 1, 1, 7004.01, 1, 40, 11, 1, 9, 1, 17 , 1, 1, 1, 1, 1, 1, 1, 7005.01, 1, 45, 10, 1, 58, 1, 35 , 1, 1, 1, 3, 2, 1, 1, 7006.01, 1, 46, 10, 1, 6, 1, 22 , 1, 2, 3, 1, 3, 2, 5, 8001.01, 1, 44, 11, 9, 2, 2, 22 , 1, 3, 3, 7, 20, 5, 3, 8002.01, 1, 21, 15, 1, 26, 1, 8 , 1, 1, 1, 1, 1, 1, 1, 8003.01, 1, 53, 10, 1, 60, 1, 20 , 1, 1, 2, 1, 2, 1, 2, 8004.01, 1, 33, 1, 8, 13, 1, 31 , 1, 4, 2, 1, 3, 5, 3, 8005.01, 1, 26, 18, 3, 14, 1, 18 , 1, 2, 3, 1, 1, 1, 1, 9001.01, 1, 40, 12, 3, 13, 1, 40 , 1, 1, 1, 1, 1, 1, 1, 9002.01, 1, 38, 11, 1, 26, 1, 19 , 2, 3, 7, 6, 3, 7, 3, 1001.02, 1, 25, 17, 9, 36, 1, 22 , 2, 10, 10, 10, 3, 8, 5, 1002.02, 1, 30, 18, 1, 2, 2, 30 , 2, 6, 7, 6, 5, 6, 5, 1003.02, 2, 59, 11, 19, 12, 2, 21 , 2, 3, 5, 3, 1, 5, 1, 1004.02, 2, 33, 20, 3, 32, 2, 26 , 2, 7, 11, 7, 6, 11, 6, 1005.02, 1, 25, 8, 1, 24, 1, 14 , 2, 14, 18, 2, 2, 7, 3, 1006.02, 2, 34, 11, 1, 16, 1, 30 , 2, 5, 8, 5, 2, 2, 2, 1007.02, 1, 29, 10, 1, 27, 1, 15 , 2, 4, 6, 4, 3, 4, 3, 1008.02, 1, 26, 11, 1, 5, 1, 26 , 2, 5, 3, 3, 4, 3, 3, 1009.02, 2, 58, 11, 1, 20, 2, 30 , 2, 5, 6, 4, 5, 4, 4, 1010.02, 2, 30, 10, 3, 7, 2, 24 , 2, 5, 5, 5, 3, 3, 5, 1011.02, 1, 42, 16, 1, 9, 1, 16 , 2, 5, 3, 3, 5, 4, 3, 3001.02, 1, 37, 10, 4, 4, 1, 22 , 2, 3, 3, 3, 3, 3, 3, 3002.02, 1, 52, 15, 2, 20, 1, 32 , 2, 3, 6, 7, 5, 3, 3, 3003.02, 2, 23, 15, 4, 24, 1, 19 , 2, 1, 1, 1, 1, 1, 1, 3004.02, 2, 48, 11, 4, 24, 1, 28 , 2, 9, 5, 5, 8, 5, 6, 3006.02, 1, 40, 13, 1, 20, 1, 9999 , 2, 6, 3, 2, 7, 3, 3, 3007.02, 2, 28, 17, 3, 364, 1, 21 , 2, 4, 1, 1, 1, 1, 2, 4001.02, 1, 30, 9, 1, 10, 1, 20 , 2, 1, 1, 1, 1, 1, 3, 4002.02, 1, 39, 13, 1, 17, 1, 19 , 2, 20, 20, 20, 20, 20, 20, 4003.02, 1, 35, 16, 1, 4, 1, 29 , 2, 3, 3, 3, 1, 1, 1, 4004.02, 1, 46, 12, 15, 4, 1, 20 , 2, 8, 5, 8, 11, 9, 7, 4005.02, 1, 27, 10, 1, 12, 1, 17 , 2, 20, 20, 20, 20, 20, 20, 7001.02, 1, 28, 20, 11, 3, 1, 28 , 2, 2, 4, 4, 2, 2, 2, 8001.02, 2, 22, 10, 1, 25, 2, 13 , 2, 3, 3, 3, 2, 5, 3, 8002.02, 2, 25, 11, 1, 56, 1, 16 , 2, 2, 2, 2, 1, 2, 2, 8003.02, 1, 46, 15, 3, 12, 1, 19 , 2, 3, 8, 5, 5, 7, 5, 8004.02, 2, 33, 11, 1, 6, 1, 11 , 2, 5, 5, 5, 2, 4, 3, 9001.02, 1, 25, 11, 1, 12, 1, 24 , 2, 2, 3, 2, 3, 5, 3, 9002.02, 1, 30, 11, 1, 12, 1, 19 , 4, 1, 3, 3, 3, 4, 2, 1001.03, 1, 43, 11, 2, 0, 0, 0 , 4, 6, 8, 5, 3, 5, 3, 1002.03, 2, 56, 10, 20, 0, 0, 0 , 4, 6, 7, 6, 5, 9, 5, 1003.03, 2, 24, 17, 2, 0, 0, 0 , 4, 10, 5, 7, 5, 8, 3, 1004.03, 2, 23, 17, 1, 0, 0, 0 , 4, 3, 5, 3, 3, 5, 3, 1005.03, 2, 24, 19, 1, 0, 0, 0 , 4, 6, 7, 6, 6, 8, 5, 1006.03, 1, 52, 16, 2, 0, 0, 0 , 4, 5, 5, 5, 5, 7, 5, 1007.03, 2, 51, 10, 2, 0, 0, 0 , 4, 3, 3, 3, 3, 5, 3, 1008.03, 1, 40, 11, 1, 0, 0, 0 , 4, 2, 3, 3, 3, 5, 3, 1009.03, 1, 34, 13, 1, 0, 0, 0 , 4, 6, 5, 5, 2, 7, 3, 1010.03, 2, 29, 13, 2, 0, 0, 0 , 4, 3, 3, 2, 2, 5, 3, 1011.03, 1, 25, 12, 1, 0, 0, 0 , 4, 4, 6, 6, 5, 5, 3, 1012.03, 1, 32, 13, 1, 0, 0, 0 , 4, 3, 3, 2, 3, 2, 6, 1013.03, 1, 49, 13, 1, 0, 0, 0 , 4, 6, 7, 6, 6, 7, 5, 1014.03, 1, 45, 11, 1, 0, 0, 0 , 4, 3, 3, 3, 2, 3, 3, 1015.03, 2, 42, 15, 1, 0, 0, 0 , 4, 4, 5, 3, 4, 6, 5, 3001.03, 1, 54, 11, 1, 0, 0, 0 , 4, 8, 4, 4, 1, 1, 1, 3002.03, 2, 40, 11, 1, 0, 0, 0 , 4, 10, 5, 4, 3, 2, 2, 3003.03, 2, 62, 13, 1, 0, 0, 0 , 4, 1, 1, 1, 1, 1, 1, 3004.03, 2, 44, 13, 1, 0, 0, 0 , 4, 1, 2, 2, 3, 2, 3, 3005.03, 2, 54, 11, 1, 0, 0, 0 , 4, 7, 9, 7, 5, 5, 5, 3006.03, 2, 46, 13, 5, 0, 0, 0 , 4, 1, 1, 1, 1, 1, 1, 3007.03, 2, 61, 10, 5, 0, 0, 0 , 4, 13, 8, 7, 8, 6, 7, 3008.03, 2, 64, 11, 1, 0, 0, 0 , 4, 2, 1, 2, 1, 1, 2, 4001.03, 2, 59, 10, 1, 0, 0, 0 , 4, 5, 11, 5, 5, 8, 5, 4002.03, 1, 28, 16, 1, 0, 0, 0 , 4, 6, 14, 6, 6, 9, 5, 4003.03, 1, 27, 11, 1, 0, 0, 0 , 4, 3, 8, 6, 16, 11, 17, 7001.03, 1, 27, 15, 1, 0, 0, 0 , 4, 11, 10, 10, 3, 6, 3, 7002.03, 2, 22, 13, 1, 0, 0, 0 , 4, 12, 14, 14, 10, 15, 10, 7003.03, 2, 22, 13, 1, 0, 0, 0 , 4, 12, 14, 14, 10, 15, 10, 7004.03, 2, 42, 13, 1, 0, 0, 0 , 4, 3, 7, 3, 3, 5, 3, 8001.03, 2, 21, 16, 1, 0, 0, 0 , 4, 7, 16, 7, 7, 11, 6, 9001.03, 1, 23, 17, 1, 0, 0, 0 , 4, 5, 6, 5, 3, 8, 3, 9002.03, 1, 23, 11, 1, 0, 0, 0 , 5, 2, 3, 1, 1, 1, 1, 1001.04, 1, 65, 10, 1, 8, 7, 65 , 5, 2, 1, 3, 1, 1, 1, 3001.04, 1, 81, 9, 1, 5, 7, 81 , 5, 3, 2, 1, 5, 3, 3, 3003.04, 2, 86, 4, 2, 832, 7, 70 , 5, 1, 1, 1, 2, 1, 1, 3004.04, 2, 71, 11, 4, 156, 7, 62 , 5, 1, 1, 1, 3, 1, 1, 3005.04, 2, 71, 11, 2, 24, 7, 70 , 5, 13, 7, 6, 6, 3, 3, 3006.04, 1, 69, 10, 4, 160, 7, 66 , 5, 2, 2, 2, 4, 3, 3, 3007.04, 1, 82, 10, 6, 8, 7, 80 , 5, 8, 8, 7, 20, 14, 17, 3009.04, 1, 66, 11, 4, 4, 7, 60 , 5, 1, 1, 1, 1, 2, 2, 3010.04, 2, 72, 11, 4, 312, 7, 66 , 5, 11, 9, 10, 17, 20, 20, 3011.04, 1, 70, 9, 1, 287, 7, 64 , 5, 1, 1, 1, 1, 1, 1, 3012.04, 2, 74, 11, 4, 10, 3, 74 , 5, 7, 4, 4, 3, 2, 3, 3013.04, 2, 79, 9, 1, 156, 3, 76 , 5, 1, 1, 1, 8, 3, 3, 3014.04, 2, 74, 8, 4, 68, 7, 72 , 5, 8, 5, 5, 7, 5, 5, 3015.04, 1, 72, 16, 1, 120, 7, 69 , 5, 9, 3, 3, 1, 1, 1, 3016.04, 2, 80, 10, 1, 208, 7, 76 , 5, 20, 18, 20, 1, 1, 1, 3017.04, 2, 84, 9, 1, 9, 7, 84 , 5, 7, 4, 3, 1, 1, 1, 3018.04, 2, 76, 9, 1, 8, 7, 75 , 5, 1, 1, 1, 1, 1, 1, 3019.04, 1, 82, 9, 1, 1056, 7, 60 , 5, 1, 1, 1, 2, 1, 1, 3020.04, 2, 78, 10, 1, 5, 7, 78 , 5, 5, 1, 2, 7, 1, 1, 3022.04, 2, 84, 16, 20, 364, 7, 77 , 5, 1, 1, 1, 3, 2, 5, 3023.04, 2, 86, 11, 2, 16, 7, 85 , 5, 1, 1, 1, 1, 1, 1, 4001.04, 1, 76, 9, 1, 6, 7, 71 , 5, 3, 2, 1, 5, 3, 3, 4002.04, 2, 78, 9, 1, 64, 7, 77 , 5, 1, 1, 1, 1, 1, 1, 4003.04, 2, 70, 8, 1, 28, 7, 68 , 5, 8, 8, 9, 6, 7, 6, 4004.04, 2, 79, 9, 1, 22, 7, 69 , 5, 1, 1, 1, 1, 1, 1, 4005.04, 2, 81, 9, 1, 196, 7, 78 , 5, 7, 4, 4, 2, 3, 3, 4006.04, 2, 84, 9, 1, 28, 7, 71 , 6, 3, 8, 5, 5, 7, 3, 1001.05, 1, 29, 14, 1, 7, 5, 29 , 6, 7, 6, 5, 7, 10, 4, 1002.05, 1, 43, 11, 1, 5, 5, 21 , 6, 3, 7, 3, 2, 5, 3, 1003.05, 1, 35, 11, 1, 15, 5, 32 , 6, 5, 5, 5, 5, 5, 5, 1004.05, 1, 9999, 9999, 1, 8, 5, 9999 , 6, 3, 8, 7, 3, 3, 3, 1005.05, 1, 45, 11, 1, 22, 5, 30 , 6, 10, 8, 7, 5, 5, 6, 1006.05, 1, 39, 11, 1, 15, 5, 32 , 6, 5, 6, 5, 3, 3, 3, 1007.05, 2, 30, 11, 1, 15, 6, 18 , 6, 5, 5, 5, 6, 6, 6, 1008.05, 1, 31, 18, 1, 8, 6, 27 , 6, 6, 5, 4, 3, 2, 3, 1009.05, 2, 42, 12, 1, 34, 5, 13 , 6, 2, 3, 3, 3, 5, 2, 4001.05, 1, 27, 11, 1, 8, 4, 15 , 6, 1, 1, 1, 1, 1, 1, 4002.05, 2, 22, 14, 1, 14, 6, 19 , 6, 1, 1, 1, 1, 1, 1, 7001.05, 2, 42, 10, 1, 12, 5, 14 , 6, 4, 5, 4, 9, 9, 7, 8001.05, 1, 24, 19, 1, 645, 4, 12 , 6, 2, 3, 3, 2, 2, 2, 8002.05, 2, 25, 16, 1, 696, 4, 12 , 6, 3, 7, 3, 1, 1, 1, 8004.05, 2, 22, 17, 1, 72, 4, 7 , 6, 2, 4, 3, 2, 4, 4, 9001.05, 2, 50, 11, 1, 9, 5, 25 , 6, 3, 3, 3, 2, 4, 2, 9002.05, 1, 48, 11, 1, 32, 5, 42 , 6, 1, 2, 1, 1, 1, 1, 9003.05, 1, 36, 11, 3, 4, 5, 33 , 6, 3, 6, 3, 3, 5, 2, 9004.05, 2, 38, 10, 1, 48, 5, 14 , 6, 2, 1, 1, 1, 1, 1, 9005.05, 2, 56, 13, 1, 26, 5, 52 , 7, 7, 7, 8, 20, 20, 20, 1001.06, 2, 47, 17, 1, 104, 4, 41 , 7, 3, 3, 4, 5, 4, 5, 1002.06, 2, 46, 10, 4, 31, 4, 17 , 7, 5, 5, 3, 5, 2, 4, 1003.06, 2, 56, 11, 1, 11, 4, 55 , 7, 6, 7, 3, 3, 5, 3, 1004.06, 2, 41, 10, 1, 9, 4, 11 , 7, 5, 6, 5, 4, 7, 5, 1005.06, 2, 62, 10, 1, 7, 4, 51 , 7, 5, 8, 5, 6, 9, 8, 1006.06, 1, 56, 17, 1, 392, 4, 11 , 7, 6, 5, 4, 6, 8, 5, 1007.06, 1, 63, 16, 1, 21, 4, 38 , 7, 6, 9, 6, 5, 7, 5, 1008.06, 2, 57, 18, 1, 364, 4, 11 , 7, 6, 7, 5, 4, 5, 3, 1009.06, 1, 54, 10, 2, 260, 4, 10 , 7, 3, 3, 3, 2, 5, 2, 1010.06, 2, 20, 15, 1, 2, 4, 16 , 7, 9, 14, 10, 7, 18, 8, 1011.06, 2, 37, 18, 1, 112, 4, 28 , 7, 7, 5, 3, 3, 8, 3, 1012.06, 2, 60, 12, 1, 77, 4, 37 , 7, 7, 6, 4, 2, 2, 3, 1013.06, 2, 61, 12, 1, 6, 4, 60 , 7, 9, 10, 9, 8, 6, 5, 3001.05, 1, 51, 10, 1, 236, 4, 20 , 7, 9, 6, 6, 7, 5, 6, 3002.06, 1, 53, 16, 1, 77, 4, 30 , 7, 5, 4, 5, 3, 3, 3, 3003.06, 2, 46, 10, 1, 56, 4, 28 , 7, 1, 1, 1, 1, 1, 1, 4001.06, 2, 35, 12, 1, 105, 4, 33 , 7, 5, 6, 5, 5, 8, 5, 4002.06, 1, 51, 16, 1, 3, 4, 30 , 7, 3, 4, 4, 11, 10, 7, 7002.06, 2, 59, 9, 2, 3, 4, 30 , 7, 1, 1, 1, 1, 1, 1, 8001.06, 2, 55, 12, 1, 22, 4, 18 , 7, 3, 5, 3, 1, 1, 2, 8002.06, 1, 38, 16, 1, 1400, 4, 15 , 7, 2, 3, 2, 2, 1, 2, 8003.06, 2, 53, 15, 1, 37, 4, 44 , 7, 2, 8, 4, 2, 8, 3, 8005.06, 2, 38, 16, 1, 12, 4, 23 , 7, 3, 7, 3, 2, 5, 2, 9001.06, 2, 30, 17, 1, 60, 4, 18 , 7, 4, 8, 3, 3, 4, 2, 9002.06, 2, 56, 10, 1, 1, 4, 52 , 7, 3, 7, 7, 1, 1, 1, 9004.06, 1, 34, 19, 1, 23, 4, 34 , 8, 1, 1, 1, 5, 3, 2, 3001.07, 1, 85, 9, 1, 104, 4, 72 , 8, 1, 1, 1, 1, 1, 1, 3002.07, 1, 70, 9, 1, 480, 4, 60 , 8, 5, 6, 6, 8, 8, 8, 3003.07, 2, 69, 9, 1, 16, 4, 69 , 8, 1, 1, 1, 1, 1, 1, 3004.07, 1, 89, 9, 1, 388, 4, 81 , 8, 4, 3, 3, 3, 3, 3, 3005.07, 2, 78, 8, 1, 84, 4, 66 , 8, 1, 1, 1, 1, 1, 3, 3006.07, 1, 74, 9, 2, 52, 4, 73 , 8, 1, 1, 1, 1, 1, 2, 3007.07, 2, 81, 9, 1, 106, 4, 77 , 8, 1, 1, 1, 1, 1, 1, 3008.07, 1, 79, 9, 1, 192, 4, 75 , 8, 1, 2, 1, 6, 5, 3, 3009.07, 1, 69, 10, 1, 4, 4, 66 , 8, 4, 4, 4, 4, 4, 4, 3010.07, 1, 68, 9, 4, 36, 4, 64 , 8, 1, 1, 1, 1, 1, 1, 3011.07, 2, 77, 11, 4, 16, 4, 74 , 8, 1, 1, 1, 1, 1, 1, 3012.07, 2, 94, 11, 1, 196, 4, 90 , 8, 1, 1, 1, 1, 1, 1, 3013.07, 2, 72, 12, 1, 4, 4, 70 , 8, 1, 1, 1, 1, 1, 1, 3014.07, 1, 68, 13, 8, 28, 4, 67 , 8, 1, 1, 1, 1, 1, 1, 3015.07, 2, 74, 9, 1, 76, 4, 72 , 8, 1, 2, 2, 1, 1, 1, 3016.07, 2, 81, 9, 1, 7, 4, 81 , 8, 1, 1, 1, 2, 1, 1, 3017.07, 2, 71, 10, 1, 128, 4, 66 , 8, 2, 3, 3, 1, 1, 1, 3018.07, 2, 77, 14, 17, 52, 4, 60 , 8, 1, 1, 1, 1, 1, 1, 3019.07, 1, 84, 11, 1, 24, 4, 83 , 8, 1, 2, 2, 1, 1, 1, 3020.07, 1, 74, 11, 1, 2, 4, 64 , 8, 4, 3, 4, 5, 5, 5, 4001.07, 2, 84, 9, 1, 28, 4, 81 , 8, 5, 6, 5, 6, 7, 7, 4002.07, 1, 81, 8, 1, 37, 4, 71 , 8, 12, 9, 10, 8, 8, 6, 4003.07, 1, 76, 9, 1, 28, 4, 72 , 8, 20, 20, 20, 20, 20, 20, 4004.07, 2, 93, 7, 1, 32, 4, 82 , 8, 8, 6, 8, 11, 10, 8, 4005.07, 2, 85, 6, 1, 28, 4, 85 , 8, 20, 20, 20, 20, 20, 20, 4006.07, 1, 78, 9, 1, 226, 4, 75 , 8, 1, 1, 1, 1, 1, 1, 4007.07, 2, 66, 9, 1, 50, 4, 0 , 8, 14, 13, 12, 14, 14, 11, 9001.07, 2, 89, 9, 1, 120, 4, 87 , 9, 2, 8, 7, 3, 4, 2, 1001.08, 2, 66, 10, 1, 0, 0, 0 , 9, 8, 6, 3, 5, 4, 4, 3001.08, 2, 78, 8, 1, 0, 0, 0 , 9, 1, 1, 1, 2, 1, 1, 3002.08, 2, 78, 9, 1, 0, 0, 0 , 9, 8, 5, 3, 5, 3, 3, 3003.08, 1, 83, 10, 1, 0, 0, 0 , 9, 11, 7, 7, 7, 5, 5, 3004.08, 1, 76, 14, 1, 0, 0, 0 , 9, 20, 20, 20, 20, 20, 20, 3005.08, 2, 80, 8, 1, 0, 0, 0 , 9, 9, 5, 5, 7, 5, 5, 3006.08, 2, 67, 11, 1, 0, 0, 0 , 9, 3, 7, 7, 3, 6, 5, 3007.08, 1, 72, 10, 2, 0, 0, 0 , 9, 11, 5, 5, 8, 6, 7, 3008.08, 1, 76, 13, 2, 0, 0, 0 , 9, 7, 3, 3, 1, 1, 1, 3009.08, 2, 73, 12, 2, 0, 0, 0 , 9, 8, 7, 7, 9, 10, 5, 3010.08, 2, 87, 9, 1, 0, 0, 0 , 9, 9, 7, 7, 9, 5, 5, 3011.08, 2, 71, 9, 1, 0, 0, 0 , 9, 8, 5, 4, 3, 4, 3, 3012.08, 2, 79, 9, 1, 0, 0, 0 , 9, 2, 11, 6, 20, 20, 20, 3013.08, 2, 83, 11, 2, 0, 0, 0 , 9, 2, 1, 1, 1, 1, 3, 3015.08, 1, 77, 10, 1, 0, 0, 0 , 9, 1, 1, 1, 1, 1, 1, 3016.08, 1, 66, 11, 1, 0, 0, 0 , 9, 8, 6, 3, 7, 5, 5, 3017.08, 2, 69, 12, 1, 0, 0, 0 , 9, 5, 3, 2, 1, 1, 1, 3018.08, 2, 74, 9, 1, 0, 0, 0 , 9, 5, 3, 2, 1, 1, 2, 3019.08, 2, 75, 9, 1, 0, 0, 0 , 9, 1, 1, 1, 1, 1, 1, 3021.08, 2, 77, 9, 1, 0, 0, 0 , 9, 1, 1, 1, 1, 1, 1, 3023.08, 2, 74, 13, 1, 0, 0, 0 , 9, 1, 1, 1, 1, 1, 1, 3024.08, 1, 84, 10, 1, 0, 0, 0 , 9, 1, 1, 1, 1, 1, 1, 3025.08, 1, 77, 9, 1, 0, 0, 0 , 9, 2, 1, 1, 1, 1, 1, 3026.08, 2, 75, 9, 1, 0, 0, 0 , 9, 1, 1, 3, 1, 1, 1, 3027.08, 2, 75, 9, 1, 0, 0, 0 , 9, 1, 1, 2, 1, 3, 2, 3028.08, 2, 82, 9, 1, 0, 0, 0 , 9, 1, 1, 1, 1, 1, 1, 3029.08, 2, 67, 11, 1, 0, 0, 0 , 9, 3, 7, 4, 20, 10, 10, 7001.08, 2, 72, 16, 1, 0, 0, 0 , 9, 20, 18, 13, 10, 14, 8, 7002.08, 2, 75, 16, 1, 0, 0, 0 , 9, 3, 7, 3, 1, 1, 1, 9001.08, 1, 72, 19, 1, 0, 0, 0 ; // end of 229 x 15 experimental data array ! // intitiate valid participant number array: validN = new int[10]; validN[0] = 0; validN[3] = 0; // no such groups exist. validN[1] = 36; validN[2] = 29; validN[4] = 33 ; // the younger validN[6] = 20; validN[7] = 26; validN[5] = 27; validN[8] = 28; validN[9] = 30 ; // the older // Mackintosh - El-Deredy expt. params : meRetN = 3; //Number of different reward/cost pattern in ME1 ... CS1=-5.0; R1=100.0; CS2=-10.0; R2=-200.0; // meCS and R0 to be chosen from these. // Mackintosh - El-Deredy expt. ME1, ALL data: ME1JTC.resize(Range(1,60), Range(1,6)) ; // d2d0 d2dLo d2dHi Stim0 StimLo StimHi ME1JTC= 10, 5, 8, 1, 1, 2 , 20, 5, 1, 1, 1, 2 , 7, 6, 5, 1, 1, 2 , 13, 5, 5, 1, 1, 2 , 8, 4, 4, 1, 1, 2 , 7, 4, 5, 1, 1, 2 , 9, 9, 5, 1, 1, 2 , 8, 7, 4, 1, 1, 2 , 11, 7, 5, 1, 1, 2 , 6, 4, 3, 1, 1, 2 , 11, 6, 7, 1, 1, 2 , 17, 12, 9, 1, 1, 2 , 6, 5, 7, 1, 1, 2 , 2, 3, 3, 1, 1, 2 , 19, 10, 6, 1, 1, 2 , 3, 1, 0, 1, 1, 2 , 7, 5, 2, 1, 1, 2 , 11, 8, 6, 1, 1, 2 , 4, 4, 3, 1, 1, 2 , 7, 6, 4, 1, 1, 2 , 20, 4, 2, 1, 1, 2 , 13, 7, 3, 1, 1, 2 , 5, 3, 1, 1, 1, 2 , 20, 15, 13, 1, 1, 2 , 4, 4, 1, 1, 1, 2 , 1, 4, 1, 1, 1, 2 , 20, 3, 3, 1, 1, 2 , 10, 4, 5, 1, 1, 2 , 9, 7, 5, 1, 1, 2 , 11, 7, 4, 1, 1, 2 , 4, 5, 5, 1, 1, 2 , 6, 4, 5, 1, 1, 2 , 11, 4, 4, 1, 1, 2 , 2, 4, 2, 1, 1, 2 , 9, 6, 4, 1, 1, 2 , 14, 7, 4, 1, 1, 2 , 9, 9, 8, 1, 1, 2 , 11, 7, 4, 1, 1, 2 , 8, 4, 3, 1, 1, 2 , 8, 5, 4, 1, 1, 2 , 17, 4, 4, 3, 2, 3 , 17, 9, 4, 3, 2, 3 , 20, 3, 5, 3, 2, 3 , 7, 7, 4, 3, 2, 3 , 4, 3, 4, 3, 2, 3 , 10, 4, 6, 3, 2, 3 , 7, 5, 9, 3, 2, 3 , 16, 9, 9, 3, 2, 3 , 8, 5, 5, 3, 2, 3 , 10, 6, 4, 3, 2, 3 , 4, 4, 4, 2, 3, 1 , 6, 9, 5, 2, 3, 1 , 9, 5, 4, 2, 3, 1 , 14, 6, 8, 2, 3, 1 , 14, 2, 2, 2, 3, 1 , 10, 9, 4, 2, 3, 1 , 20, 3, 0, 2, 3, 1 , 5, 3, 3, 2, 3, 1 , 6, 3, 5, 2, 3, 1 , 5, 3, 3, 2, 3, 1 ; // end of 60 x 6 experimental data ME1 array ! // default for centiles is quartiles, i.e. vals of '0' (min), 25, 50, 75, '100' (max). centiles.resize(Range(1,5), Range(1,1+6*8)) ; // Fill in default for quartiles, beads, exp 1: centileCalc(4); // } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RBWelcomeDat::~RBWelcomeDat() { free_vector(seq1,1,20); free_vector(seq2,1,20); free_vector(seq3,1,20); free_vector(ng_seq1,0,20); free_vector(ng_seq2,0,20); free_vector(ng_seq3,0,20); free_vector(mes1,1,20); free_vector(mes2,1,20); free_vector(mes3,1,20); free_vector(ng_mes1,0,20); free_vector(ng_mes2,0,20); free_vector(ng_mes3,0,20); delete seq; // I don't think it needs parking in NULL ... delete MEseq; delete validN; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RBWelcomeDat::beadSet(int seqN, int drawN, int newVal) { if (seqN<0 || seqN>sN) Error("%s%s \n",RBWelcomeDat::ERROR,"beadSet: seqN off range"); if (drawN<1 || drawN> SamplMaxN()) Error("%s%s \n",RBWelcomeDat::ERROR,"beadSet: drawN off range"); if (newVal<0 || newVal>1) Error("%s%s \n",RBWelcomeDat::ERROR,"beadSet: newVal off range"); // now that we have made sure values are tidy, int oldVal = lround(seq[seqN][drawN]); int i; if ((newVal==1) && (oldVal==0)) { seq[seqN][drawN] += 1 ; // this is the index draw for (i=drawN; i<=SamplMaxN(); i++) ng_tot[seqN][i] += 1; // shift totals up one } else if ((newVal==0) && (oldVal==1)) { seq[seqN][drawN] -= 1 ; for (i=drawN; i<=SamplMaxN(); i++) ng_tot[seqN][i] -= 1; // shift totals down one } // Otherwise newVal and oldVal are equal, so do nothing ! } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int RBWelcomeDat::CentVal( int centile, int groupLabel, int expType, int expNum) { if (groupLabel<1 || groupLabel>9 || groupLabel==3) Error("%s%s \n",RBWelcomeDat::ERROR,"Group Label can only be 1,2,4,5,6,7,8 or 9"); int i= centiles.extent(firstDim); int gpInd = groupLabel; // this is correct only for groupLabel>3 if (groupLabel<3) gpInd +=1 ; // bec. 1st col. has the centile indices while (i>0) { // centiles array starts from 1 in both directions if (lround(centiles(i,1)) == centile) return lround(centiles(i,gpInd)); i -= 1; } // line never reached for reasonable requests: Error("%s%s \n",RBWelcomeDat::ERROR,"CentVal: Requested centile value not found"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RBWelcomeDat::centileCalc(int partNum) { centiles.resize(Range(1,partNum+1), Range(1,1+6*8)) ; int i, j, k, N, gpInd, gpLabel, expType, expInd ; int *order; // will hold index for sorting data arrays. double frac = 100.0/partNum; Array wDat; // working copy of data. // Easy bit - fill in first column: centiles(1,1) = 0; centiles(partNum+1,1) = 100; for(i=2; i<= partNum; i++) centiles(i,1) = lround((i-1)*frac); // for(expType=1; expType<=2; expType++) { // i.e. beads or words for(expInd=1; expInd<=3; expInd++) { // i.e. sequence for(gpInd=1; gpInd<=8; gpInd++) { // i.e. expt. group gpLabel = ((gpInd<3) ? gpInd : gpInd+1) ; N = validN[gpLabel] ; // prepare & fill in wDat : wDat.resize(Range(1,N)) ; k=1 ; // counts wDat rows for (j=1; j<=ptN(); j++) // go through WJTC rows if ( lround(WJTC(j,1)) == gpLabel ) { wDat(k) = WJTC(j,1+(expType-1)*3+expInd) ; k +=1; // augment index for wDat. } // now use j to go through columns: j = 1+(8*3)*(expType-1)+8*(expInd-1)+gpInd ; // find the centiles: order = new int[N+1] ; indexx(wDat,order); centiles(1,j) = quanFracVal(wDat,order,0,100,0); //'0' centile ie min. centiles(partNum+1,j) = quanFracVal(wDat,order,100,100,0); //'100',max. // now use k to count centiles rows: for(k=2; k<=partNum; k++) centiles(k,j) = quanFracVal(wDat,order,lround(centiles(k,1)),100,0); delete order; } // end loop over expt. group } // end loop over sequence } // end loop over expt. Type i.e. Beads or Words // write2DArray_csv("centiles-test.csv",centiles); debug } // method end // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Beads_Exp_I::Beads_Exp_I() : Beads(20), iter(6), IP2() { // NB iter.parNo assignement hidden here ! // First, complicated stuff to do with all the iteration parametres : // (file stuff -> look up or future !) int iparN = iter.ParNo() ; iterParPtr = new float* [iparN+1]; iterIterNo = new float* [iparN+1]; iterEndPtr = new float* [iparN+1]; // Items Costs (cf. menu1 in os2t6m.cc) : // kT :range ... and No. of pts. for iteration : kT_e = 10.01 ; kT_N = 40. ; iterParPtr[1]= &kT; iterEndPtr[1]= &kT_e; iterIterNo[1]= &kT_N; // CS :range ... and No. of pts. for iteration : CS_e = -0.001 ; CS_N = 80. ; iterParPtr[2]= &CS; iterEndPtr[2]= &CS_e; iterIterNo[2]= &CS_N; // in beads05rbw.cc only the two above are actually iterated ! CGB_e = -5.001; CGB_N = 1.0; iterParPtr[3]= &CGB; iterEndPtr[3]= &CGB_e; iterIterNo[3]= &CGB_N; // ( potentially !) the rest: q_e = .60 ; q_N = 1. ; iterParPtr[4]= &q; iterEndPtr[4]= &q_e; iterIterNo[4]= &q_N; PoG_e = 0.05; PoG_N = 1. ; iterParPtr[5]= &PoG; iterEndPtr[5]= &PoG_e; iterIterNo[5]= &PoG_N; // to iterate contr. distr. param. 1; esp. SPRT Threshold_hi CDPar1 = 0.0; CDPar1_e = 30.0; CDPar1_N=150. ; iterParPtr[6]= &CDPar1; iterEndPtr[6]= &CDPar1_e; iterIterNo[6]= &CDPar1_N; // REM MINUS rCW, -rCW, used as the ratio of lower to higher thresh. in SPRT, // and should have -rCW < 1. // rCW : range: ... and No. of pts. for iteration : rCW = 1. ; rCW_e=0.5 ; rCW_N = 1. ; // ... and contr. distr. param. 2: CDPar2 = -1.0; CDPar2_e = -.5; CDPar2_N=1. ; // Strings to help w. names of output files: ofs = new ofstream* [fN+5] ; // pointer array for 21+... filestream objects // try it out ! ofs[0]= & Pd0; ofs[1]= & Pd1; ofs[2] = & Pd2; ofs[3] = & Pd3; ofs[4] = & Pd4; ofs[5]= & Pd5; ofs[6] = & Pd6; ofs[7] = & Pd7; ofs[8] = & Pd8; ofs[9]= & Pd9; ofs[10]= & Pd10; ofs[11]= & Pd11; ofs[12]= & Pd12; ofs[13]= & Pd13; ofs[14]= & Pd14; ofs[15]= & Pd15; ofs[16]= & Pd16; ofs[17]= & Pd17; ofs[18]= & Pd18; ofs[19]= & Pd19; ofs[20]= & Pd20; ofs[21]= & l3beads; ofs[22]= & l3words; ofs[23]= & cl3beads; ofs[24]= & cl3words; ofs[25]= & results; // initialise default sequence var. & related storage array. Note 0-20 component ! seqNum = 3; seqLen=20; PVecs.resize(Range(1,roundfl(*iterIterNo[1])),Range(1,roundfl(*iterIterNo[2])),Range(1,seqNum),Range(0,seqLen)); PVecs = 0; // initialise array to hold summary etc. results for output. Default for // just one participant - resize acc. to use, e.g. for 229 in Richard's // Welcome study ! The 1 to 13 columns is as per declaration. Res.resize(Range(1,229),Range(1,15)); Res = 0; // Prepare the Itepolation object : IP2.setOrderPars(4,4); // use 4x4 set of data for interpolating a point. llrSD0=0.1; // half-descent ?? for thHi-thLo=3 and grid of ~200 points // for Mackintosh - El-Deredy stuff retNum = 3; // [local copy of] the number of different patterns of returns that // the expt. uses - e.g. 3 for ME1 that has zero, low and high. } // End of ctor for Beads_Exp_I // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Beads_Exp_I::~Beads_Exp_I() { delete iterParPtr; delete iterIterNo; delete iterEndPtr; delete ofs; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Beads_Exp_I::RefreshIter() { CBG = CGB/rCW ; // no need for CDPar2 = -rCW*CDPar1 or such like as yet. iter.Set(iterParPtr,iterEndPtr,iterIterNo); } // End of RefreshIter() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Beads_Exp_I::PreparePVecsME2() { int d3 = seqNum*retNum; PVecs.resize( Range(1,roundfl(*iterIterNo[1])), Range(1,roundfl(*iterIterNo[2])) ,Range(1,d3), Range(0,seqLen) ); PVecs = 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int Beads_Exp_I::OpenOutp() { ofs[0]->open("Pd00.csv", ios::out); ofs[1]->open("Pd01.csv", ios::out); ofs[2]->open("Pd02.csv", ios::out); ofs[3]->open("Pd03.csv", ios::out); ofs[4]->open("Pd04.csv", ios::out); ofs[5]->open("Pd05.csv", ios::out); ofs[6]->open("Pd06.csv", ios::out); ofs[7]->open("Pd07.csv", ios::out); ofs[8]->open("Pd08.csv", ios::out); ofs[9]->open("Pd09.csv", ios::out); ofs[10]->open("Pd10.csv", ios::out); ofs[11]->open("Pd11.csv", ios::out); ofs[12]->open("Pd12.csv", ios::out); ofs[13]->open("Pd13.csv", ios::out); ofs[14]->open("Pd14.csv", ios::out); ofs[15]->open("Pd15.csv", ios::out); ofs[16]->open("Pd16.csv", ios::out); ofs[17]->open("Pd17.csv", ios::out); ofs[18]->open("Pd18.csv", ios::out); ofs[19]->open("Pd19.csv", ios::out); ofs[20]->open("Pd20.csv", ios::out); ofs[21]->open("L3Beads.csv", ios::out); ofs[22]->open("L3Words.csv", ios::out); ofs[23]->open("CL3Beads.csv",ios::out); ofs[24]->open("CL3Words.csv",ios::out); ofs[25]->open("res.csv", ios::out); int i; for (i=0; iseqN()) != PVecs.extent(thirdDim)) Error("%s%s \n",Beads_Exp_I::ERROR,"RBWptr->seqN() != PVecs.extent(thirdDim) in StoreAllPVecs."); if ((RBWptr->SamplMaxN()) != (fN-1)) Error("%s%s \n",Beads_Exp_I::ERROR,"max. draw number mismatch in StoreAllPVecs."); if( (roundfl(*iterIterNo[1]) != PVecs.extent(firstDim)) || (roundfl(*iterIterNo[2]) != PVecs.extent(secondDim))) Error("%s%s \n",Beads_Exp_I::ERROR,"itern. number doesn't match PVecs extent in StoreAllPVecs."); /* cout << "*iterIterNo[1]: "<< *iterIterNo[1] << "PVecs.extent(firstDim)" << PVecs.extent(firstDim) << endl ; cout << "*iterIterNo[6]: "<< *iterIterNo[6] << "PVecs.extent(secondDim)" << PVecs.extent(secondDim) << endl ; */ int seq_n, s, initDraw, endDraw, ng; // auxiliaries double prod; initDraw = PVecs.lbound(fourthDim); endDraw=PVecs.ubound(fourthDim); for (seq_n = 1; seq_n <= (RBWptr->seqN()); seq_n++) { // now start calculating. First P(d2d=0), by hand : if (validZero){ // If subject allowed to declare at 0 draws ... PVecs(AtStepIter(1),AtStepIter(2), seq_n,initDraw) = 1-MS(1,1) ; prod = MS(1,1); // zero-draws 'sample again' Py } else { PVecs(AtStepIter(1),AtStepIter(2), seq_n,initDraw) = 0.0; prod = 1.0 ; // zero-draws OBLIGATORY 'sample again' Py ! } // now P(d2d=1) to P(d2d=SamplMaxN()) : for (s=initDraw+1; s<=endDraw; s++) { ng = roundfl(RBWptr->ng_tot[seq_n][s]) ; // the following should work for last step too: PVecs(AtStepIter(1),AtStepIter(2), seq_n, s) = prod*(1-MS(ng+1,s-ng+1)); prod *= MS(ng+1,s-ng+1); // ready for next step } } // end loop over sequences, for (seq_n = 1; seq_n <=... return 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int Beads_Exp_I::CalcMEPVecs(RBWelcomeDat *RBWptr, int validZero, int version) { // Rem: PVecs is 4-D array: param1 x param2 x sequence_Num x Probability_vector // e.g. for main costed bayesian: kT_N x CS_N x 3 (for Wellcome) x fN // if key extends don't match, abort. Should be OK if PreparePVecs1 was called. if( (RBWptr->seqN()*RBWptr->returnPatN()) != PVecs.extent(thirdDim)) { cerr<< "\nRBWptr->seqN()*RBWptr->returnPatN() :"<<(RBWptr->seqN()*RBWptr->returnPatN()); cerr<< "; PVecs.extent(thirdDim): "<< PVecs.extent(thirdDim)<SamplMaxN()) != (fN-1)) Error("%s%s \n",Beads_Exp_I::ERROR,"max. draw number mismatch in CalcMEPVecs."); if ((seqNum != RBWptr->seqN()) || (retNum != RBWptr->returnPatN())) Error("%s%s \n",Beads_Exp_I::ERROR,"seqNum or retNum mismatch in CalcMEPVecs."); if ( ( (version == 1) && ( (roundfl(*iterIterNo[1]) != PVecs.extent(firstDim)) || (roundfl(*iterIterNo[3]) != PVecs.extent(secondDim)) ) ) || ( (version == 2) && ( (roundfl(*iterIterNo[1]) != PVecs.extent(firstDim)) || (roundfl(*iterIterNo[2]) != PVecs.extent(secondDim)) ) ) ) Error("%s%s \n",Beads_Exp_I::ERROR,"itern. number doesn't match PVecs extent in CalcMEPVecs."); // debugs: cout << "\n *iterIterNo[1]: "<< *iterIterNo[1] << " PVecs.extent(firstDim): " <CS1; R0 = (ret_n-1)*RBWptr->R1; // debugs: meCS = 0; R0 =0; SoftME1_M_PG_V_QG_QB_QS_AS_MS(validZero); // different return partterns have // different MS etc !! for (seq_n = 1; seq_n <= seqNum; seq_n++) { // for each sequence, ceteris paribus ind3 = seq_n+retNum*(ret_n-1); // index of third dimension of PVecs, which // includes both return-pattern and sequence dims., really ... // Now start calculating. First P(d2d=0), by hand : if (validZero){ // If participant allowed to declare at 0 draws ... PVecs(AtStepIter(versionInd1),AtStepIter(versionInd2), ind3, initDraw) = 1-MS(1,1) ; prod = MS(1,1); // zero-draws 'sample again' Py } else { PVecs(AtStepIter(versionInd1),AtStepIter(versionInd2), ind3, initDraw) = 0.0; prod = 1.0 ; // zero-draws OBLIGATORY 'sample again' Py ! } /* debug if( (fabs(kT-6.045)<0.01) && (fabs(-195-CGB)<0.2) && (ret_n==1) && (s>17)) { cerr<<"\n In CalcMEPVecs w. kT, CGB="<ng_met[seq_n][s]) ; // the following should work for last step too: PVecs( AtStepIter(versionInd1), AtStepIter(versionInd2) ,ind3 ,s ) = prod*(1-MS(ng+1,s-ng+1)); prod *= MS(ng+1,s-ng+1); // ready for next step /* debug : if( (fabs(kT-6.045)<0.01) && (fabs(-195-CGB)<0.2) && (ret_n==1) && (s>17)) { // <<" indices are: kT_i="; // cerr<CGB) && (-15-0.01)) { cout << CGB << sepChar << CS << endl ; cout <<"part: "<< part_i << endl; aux1=roundfl(RBWptr->WJTC(part_i,(1-1)*3+2)) ; cout <<"b1: "<< aux1 ; cout << sepChar <<"Pb1: "<< PVecs(AtStepIter(1),AtStepIter(2),1,aux1 ) << endl ; aux1=roundfl(RBWptr->WJTC(part_i,(1-1)*3+3)) ; cout <<"b2: "<< aux1 ; cout << sepChar <<"Pb2: "<< PVecs(AtStepIter(1),AtStepIter(2),2,aux1 ) << endl ; aux1=roundfl(RBWptr->WJTC(part_i,(1-1)*3+4)) ; cout <<"b3: "<WJTC(part_i,(2-1)*3+2) << sepChar << endl ; cout <<"w2: "<WJTC(part_i,(2-1)*3+3) << sepChar << endl ; cout <<"w3: "<WJTC(part_i,(2-1)*3+4) << sepChar << endl << endl ; } */ } return 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int Beads_Exp_I::Write2Prod3P_2( int part_i, RBWelcomeDat *RBWptr, int check, char sepChar) { int s; int aux1; // Write to filestreams. Checking is done by Prod3P ! for (s=0; s<=1; s++) { *(ofs[fN+s]) << CS << sepChar << kT << sepChar ; *(ofs[fN+s]) <close(); else return 1; } return 0 ; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - double Beads_Exp_I::Prod3P( int part_i, RBWelcomeDat *RBWptr, int drawType, int check) { if ( check ) { if ( (drawType !=1) && (drawType !=2)) Error("%s%s \n",Beads_Exp_I::ERROR,"Prod3P: must have drawType = 1 (beads) or 2 (words) in Prod3P"); if ( (part_i < 1) || (part_i > RBWptr->WJTC.rows())) Error("%s%s \n",Beads_Exp_I::ERROR,"participant index off range in Prod3P"); // The following not necessary - can use with whatever param. pair : // if ( (iterParPtr[1] != &CS) || (iterParPtr[2] != &CGB )) // Error("%s%s \n",Beads_Exp_I::ERROR,"Prod3P: must have iterParPtr[1]=&CS AND iterParPtr[2]=CGB"); } int d1,d2,d3; d1 = roundfl( RBWptr->WJTC(part_i,(drawType-1)*3+2)) ; d2 = roundfl( RBWptr->WJTC(part_i,(drawType-1)*3+3)) ; d3 = roundfl( RBWptr->WJTC(part_i,(drawType-1)*3+4)) ; // rem PVecs.resize(1,roundfl(*iterIterNo[1])),Range(1,roundfl(*iterIterNo[2])), Range(1,RBWelc.seqN()), Range(0,20)) : return PVecs(AtStepIter(1),AtStepIter(2),1,d1)*PVecs(AtStepIter(1),AtStepIter(2),2,d2)*PVecs(AtStepIter(1),AtStepIter(2),3,d3) ; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - double Beads_Exp_I::CPDistr1(int d2d, double param) { double fact, PSum, lt; int i,j; if (param<0.0) lt=CDPar1 ; else lt = param; if (d2d<1) return 0.0; else if (d2d<(fN-1)){ //e.g. if d2d<20 for usual setup fact=1.0; // note that in both step that follow, we use d2d-1 - Poisson distro // is displaced by 1 as constrained to have P(d2d=0) = 0 for (i=1; iwidth(13); *(ofs[fN+4])<< void Beads_Exp_I::WritePtRes(RBWelcomeDat *RBWptr, int participant, int ti) { int i, ptInd, ptIndSt, ptIndE ; // counters, pt Index St_art and E_nd values. double contrL3Val, contrL3Par; if (ti) { // Title line : *(ofs[fN+4]) << "Pt.Num."; ofsTb13 "BeadsD2D1"; ofsTb13 "BeadsD2D2"; ofsTb13 "BeadsD2D3"; ofsTb13 "WordsD2D1"; ofsTb13 "WordsD2D2"; ofsTb13 "WordsD2D3"; ofsTb13 "OptL3B" ; ofsTb13 "OptPar1B"; ofsTb13 "OptPar2B"; ofsTb13 "OptPar3B"; ofsTb13 "OptL3W" ; ofsTb13 "OptPar1W"; ofsTb13 "OptPar2W" ; ofsTb13 "OptPar3W"; ofsTb13 "ContrL3B" ; ofsTb13 "ContrParB1"; ofsTb13 "ContrL3W" ; ofsTb13 "ContrParW1"; ofsTb13 "Opt/Contr_L3B" ; ofsTb13 "Opt/Contr_L3W" ; *(ofs[fN+4]) << endl ; } if(participant != 0) { ptIndSt= ptIndE = participant ; // To check if poisson-like py stuff works : ofstream cdistr ; cdistr.open("Poissonoid.csv", ios::out); for (i=0; i<21; i++) { cdistr <ptN() ; } for (ptInd=ptIndSt; ptInd<=ptIndE; ptInd++) { *(ofs[fN+4]) << ptInd ; for (i=2; i<8; i++) { // keep this even for 'single' statement' ofsTb13 RBWptr->WJTC(ptInd,i) ; } // write stored results from Bayesian Beads calculation : ofsTb13 Res(ptInd,1); // OptL3B ; ofsTb13 Res(ptInd,2); // OptPar1B; ofsTb13 Res(ptInd,3); // OptPar2B ; ofsTb13 Res(ptInd,4); // OptPar3B ; ofsTb13 Res(ptInd,5); // OptL3W ; ofsTb13 Res(ptInd,6); // OptPar1W ; ofsTb13 Res(ptInd,7); // OptPar2W ; ofsTb13 Res(ptInd,8); // OptPar3W ; // control likelihood products for current val. of contr. distr. param: ofsTb13 Res(ptInd,9); // ContrL3B ; ofsTb13 Res(ptInd,10); // ContrPar1B ; ofsTb13 Res(ptInd,11); // ContrL3W ; ofsTb13 Res(ptInd,12); // ContrPar1W ; if (Res(ptInd,9) > 0.0) { ofsTb13 Res(ptInd,1)/Res(ptInd,9) ; } if (Res(ptInd,11) > 0.0) { ofsTb13 Res(ptInd,5)/Res(ptInd,11); } *(ofs[fN+4]) << endl ; } } #undef ofsTb13 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - double Beads_Exp_I::cProd3P( RBWelcomeDat *RBWptr, int participant , double param, int drawType) { int d1,d2,d3; d1 = roundfl( RBWptr->WJTC(participant,(drawType-1)*3+2)) ; d2 = roundfl( RBWptr->WJTC(participant,(drawType-1)*3+3)) ; d3 = roundfl( RBWptr->WJTC(participant,(drawType-1)*3+4)) ; // cout <<"d1: "< bestP3VSoFar) { bestP3VSoFar = P3V ; bestParSoFar = param ; } } if (Prod3Val) *Prod3Val = bestP3VSoFar ; return bestParSoFar ; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - double Beads_Exp_I::SPRT(int step, int seq, RBWelcomeDat *RBWptr) { if (step<0 || step>20) err_msg("Beads_Exp_I::SPRT needs step 0 to 20"); if (seq == 1) return LLR_GoB( lround(RBWptr->ng_seq1[step]), step) ; else if (seq == 2) return LLR_GoB( lround(RBWptr->ng_seq2[step]), step) ; else if (seq == 3) return LLR_GoB( lround(RBWptr->ng_seq3[step]), step) ; else err_msg("Beads_Exp_I::SPRT needs seq 1 to 3"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {- - - - - - - void Beads_Exp_I::update_B_W_3L( double L3B, double L3W, int ptInd ) { int k; if (L3B > Res(ptInd,1)) { // Col.1 of Res is Bayesian Likelihood of 3 Beads-result estimate Res(ptInd,1) = L3B; // the updated best likelihood for (k=1; k<=3; k++) Res(ptInd,k+1) = *iterParPtr[k] ; // the param. sp. point } if (L3W > Res(ptInd,5)) { Res(ptInd,5) = L3W; for (k=1; k<=3; k++) Res(ptInd,k+5) = *iterParPtr[k] ; // the param. sp. point } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Beads_Exp_I::contr1Res(RBWelcomeDat *RBWptr) { if ( Res.rows() != RBWptr->ptN() ) Error("%s%s \n",Beads_Exp_I::ERROR,"contr1Res: expt.data vs storage array mismatch"); int i; double contrL3B, contrL3ParB, contrL3W, contrL3ParW ; for (i=1; i<=RBWptr->ptN() ; i++) { // for each participant ... contrL3ParB = bestP3PPoissonoidParam(RBWptr, i, 1, &contrL3B ); contrL3ParW = bestP3PPoissonoidParam(RBWptr, i, 2, &contrL3W ); Res(i,9) = contrL3B; Res(i,10) = contrL3ParB; Res(i,11)= contrL3W; Res(i,12) = contrL3ParW; } // end of loop over participants } //============================================================================= // end of File jtc_exp.cc