Example #1
0
 def simulate_dpm(self, p, analyze=True):
     """ Simulate the dependent process model (DPM)
     ::Arguments::
         p (dict):
             parameter dictionary. values
         analyze (bool <True>):
             if True (default) return rt and accuracy information
             else, return Go and Stop decision traces.
     ::Returns::
         yhat of cost vector (ndarray)
         or list of decision traces (list of ndarrays)
     """
     p = self.vectorize_params(p)
     nl, ntot, dx = self.nlevels, self.ntot, self.dx
     ssd, nssd, nss, nss_per, ssd_ix = self.ssd_info
     Pg, Ps, nTime, ssOn = self.__update_trace_params__(p)
     # generate Go traces (nlevels, ntrials, ntimepoints)
     xtb = np.cosh(p['xb'][:,None] * self.xtime[:nTime])
     DVg = xtb[:,na] * csum(np.where(self.rvector[:,:,:nTime].T < Pg, dx, -dx).T, axis=2)
     ssDVg = DVg[:, :nss, :].reshape(nl, nssd, nss_per, nTime)
     # use array-indexing to initialize SS at DVg[:nlevels, :ssd, :trials, t=SSD]
     ssBase = ssDVg[np.arange(nl)[:,na], ssd_ix, :, ssOn]
     # add ssBaseline to SS traces (nlevels, nSSD, ntrials_perssd, ntimepoints)
     DVs = ssBase[:,:,:,na] + csum(np.where(self.rvector_ss[:,:,:,:nTime].T < Ps, dx, -dx).T, axis=3)
     if analyze:
         return self.analyze_fx(DVg, DVs, p)
     return [DVg, DVs]
Example #2
0
 def simulate_irace(self, p, analyze=True):
     """ simulate the independent race model
     (see simulate_dpm() for I/O details)
     """
     p = self.vectorize_params(p)
     nl, ntot, dx = self.nlevels, self.ntot, self.dx
     ssd, nssd, nss, nss_per, ssd_ix = self.ssd_info
     Pg, Ps, ss_on = self.__update_trace_params__(p)
     # generate Go traces (nlevels, ntrials, ntimepoints)
     DVg = self.xtb[:,na] * csum(np.where(self.rvector.T < Pg, dx, -dx).T, axis=2)
     # generate SS traces (nlevels, nSSD, ntrials_perssd, ntimepoints)
     DVs = csum(np.where(self.rvector_ss.T < Ps, dx, -dx).T, axis=3)
     if analyze:
         return self.analyze_fx(DVg, DVs, p)
     return [DVg, DVs]
Example #3
0
 def __update_rand_vectors__(self):
     """ update rvector (random_floats) for Go and Stop traces
     """
     nl, ntot, nTime = self.nlevels, self.ntot, self.ntime
     self.xtime = csum([self.dt] * nTime)
     self.rvector = rs((nl, ntot, nTime))
     if self.include_ss:
         ssd, nssd, nss, nss_per, ssd_ix = self.ssd_info
         self.rvector_ss = rs((nl, nssd, nss_per, nTime))
Example #4
0
 def simulate_pro(self, p, analyze=True):
     """ Simulate the proactive competition model
     (see simulate_dpm() for I/O details)
     """
     p = self.vectorize_params(p)
     nl, ntot, dx = self.nlevels, self.ntot, self.dx
     Pg = self.__update_trace_params__(p)
     # generate Go traces (nlevels, ntrials, ntimepoints)
     DVg = self.xtb[:,na] * csum(np.where(self.rvector.T < Pg, dx, -dx).T, axis=2)
     if analyze:
         return self.analyze_fx(DVg, p)
     return DVg
Example #5
0
    def simulate_rldpm(self, p, analyze=True):
        """ Simulate the dependent process model (DPM)
        with learning
        """
        p = self.vectorize_params(p)
        Pg, xtb, Ps, ss_on = self.__update_go_process__(p)
        nl, ntot, dx = self.nlevels, self.ntot, self.dx
        ssd, nssd, nss, nss_per, ssd_ix = self.ssd_info

        for trial in xrange(ntot):
            DVg = xtb[:, na] * csum(np.where(self.rvector[:, trial, :].T < Pg, dx, -dx).T, axis=2)
            # INITIALIZE DVs FROM DVg(t=SSD)
            if trial%2:
                DVg[:, ]
                ssBase = ssDVg[np.arange(nl)[:,na], ssd, :, ss_on][:,:,:,na]
                DVs = ssBase + csum(np.where(self.rvector_ss.T < Ps, dx, -dx).T, axis=3)
                #ssBase = DVg[np.arange(nl)[:,na], ssd_ix, :, ss_on][:,:,:,na]
                #DVs = init_ss[:,:,na] + csum(np.where(rs((nss, Ts.max()))<Ps, dx, -dx), axis=1)
                DVs = csum(np.where(rs((nl, Ts.max()))<Ps, dx, -dx), axis=1)
        if analyze:
            return self.analyze_fx(DVg, DVs, p)
        return [DVg, DVs]
Example #6
0
 def __update_trace_params__(self, p):
     """ update Pg (probability of DVg +dx) and Tg (n timepoints)
     for go process and get get dynamic bias signal if 'x' model
     """
     Pg = 0.5 * (1 + p['v'] * self.dx / self.si)
     Tg = np.ceil((self.tb - p['tr']) / self.dt).astype(int)
     self.ntime_new = Tg.max()
     out = [Pg]
     if self.include_ss:
         out.extend(self.__update_ss_trace_params__(p, Tg))
     if self.ntime_new > self.ntime:
         self.ntime = self.ntime_new
         self.__update_rand_vectors__()
     self.xtb = self.dynamics_fx(p, csum([self.dt] * self.ntime))
     return out