void pnt_bars(QSP_ARG_DECL FILE *fp, Trial_Class *tcp) { int j; Data_Tbl *dtp; float upper_bar, lower_bar; if( tcp == NULL ) return; dtp=CLASS_DATA_TBL(tcp); for(j=0;j<_nvals;j++){ if( DATUM_NTOTAL(DTBL_ENTRY(dtp,j)) > 0 ){ fprintf(fp,"%f\t", xval_array[ j ]); n_obs = DATUM_NTOTAL(DTBL_ENTRY(dtp,j)); n_seen = DATUM_NCORR(DTBL_ENTRY(dtp,j)); fprintf(fp,"%f\t",(double) n_seen / (double) n_obs ); if( n_obs == n_seen ) upper_bar=1.0; else { if( n_seen == 0 ) alpha = (float) ALPHA; else alpha = (float) ALPHA/2; get_bar(QSP_ARG j,u_confidence,&upper_bar); } if( n_seen == 0 ) lower_bar=0.0; else { if( n_obs == n_seen ) alpha = (float) ALPHA; else alpha = (float) ALPHA/2; get_bar(QSP_ARG j,l_confidence,&lower_bar); } fprintf(fp,"%f\t%f\n",lower_bar,upper_bar); } } fclose(fp); }
void note_trial(Trial_Class *tcp,int val,int rsp,int crct) { Data_Tbl *dtp; dtp = CLASS_DATA_TBL(tcp); assert( dtp != NULL ); if( rsp == crct ) SET_DATUM_NCORR( DTBL_ENTRY(dtp,val), 1 + DATUM_NCORR( DTBL_ENTRY(dtp,val) ) ); if( rsp != REDO && rsp != ABORT ) SET_DATUM_NTOTAL( DTBL_ENTRY(dtp,val), 1 + DATUM_NTOTAL( DTBL_ENTRY(dtp,val) ) ); }
static float w_likelihood(SINGLE_QSP_ARG_DECL) /* called from optimize; return likelihood of guess */ { float lh=0.0,lhinc; int i; int ntt, /* number of total trials */ nc; /* number "correct" */ float pc,xv; float t_alpha, t_beta; /* trial slope and int */ Opt_Param *opp; /* compute the likelihood for this guess */ opp=get_opt_param(QSP_ARG ALPHA_NAME); //#ifdef CAUTIOUS // if( opp==NO_OPT_PARAM ){ // ERROR1("CAUTIOUS: missing alpha param"); // IOS_RETURN_VAL(0) // } //#endif assert( opp != NO_OPT_PARAM ); t_alpha = opp->ans; opp=get_opt_param(QSP_ARG BETA_NAME); //#ifdef CAUTIOUS // if( opp==NO_OPT_PARAM ){ // ERROR1("CAUTIOUS: missing beta param"); // IOS_RETURN_VAL(0) // } //#endif assert( opp != NO_OPT_PARAM ); t_beta = opp->ans; for(i=0;i<_nvals;i++){ /* calculate theoretical percent correct with this guess */ if( (ntt=DATUM_NTOTAL(DTBL_ENTRY(the_dtp,i)) ) <= 0 ) continue; nc=DATUM_NCORR( DTBL_ENTRY(the_dtp,i) ); xv = xval_array[ i ]; if( xv == 0.0 ) pc = (float) w_gamma; else { pc = (float) (1 - (1-w_gamma)*exp(-pow( xv/t_alpha, t_beta ) )); if( pc > (1-error_rate) ) pc =(float) ( 1-error_rate); } /* pc is the theoretical % correct at this xval */ lhinc = (float) (nc * log( pc ) + ( ntt - nc ) * log( 1 - pc )); lh -= lhinc; } /* return the answer */ return(lh); }