def apply(self, solution): # If large reward is correct, take some of the error # distribution and add it to the correct distribution. if solution.conditions['highreward'] == 1: mismapped = self.mappingcoef * solution.err err = solution.err - mismapped corr = solution.corr + mismapped return ddm.Solution(corr, err, solution.model, solution.conditions) # If small reward is correct, do the opposite else: mismapped = self.mappingcoef * solution.corr corr = solution.corr - mismapped err = solution.err + mismapped return ddm.Solution(corr, err, solution.model, solution.conditions)
def apply(self, solution): assert self.pmixturecoef >= 0 and self.pmixturecoef <= 1 corr, err, m, cond = solution.corr, solution.err, solution.model, solution.conditions # These aren't real pdfs since they don't sum to 1, they sum # to 1/self.model.dt. We can't just sum the correct and error # distributions to find this number because that would exclude # the undecided trials. pdfsum = 1 / m.dt # This can be derived by hand pretty easily. lapses_hr = lambda t: self.ratehr * np.exp(-(self.ratehr + self.ratelr) * t) if t != 0 else 0 lapses_lr = lambda t: self.ratelr * np.exp(-(self.ratehr + self.ratelr) * t) if t != 0 else 0 X = [i * m.dt for i in range(0, len(corr))] # Bias should be based on reward, not correct vs error if cond['highreward'] == 1: Y_corr = np.asarray(list(map(lapses_hr, X))) * m.dt Y_err = np.asarray(list(map(lapses_lr, X))) * m.dt else: Y_corr = np.asarray(list(map(lapses_lr, X))) * m.dt Y_err = np.asarray(list(map(lapses_hr, X))) * m.dt corr = corr * ( 1 - self.pmixturecoef ) + self.pmixturecoef * Y_corr # Assume ndarrays, not lists err = err * (1 - self.pmixturecoef) + self.pmixturecoef * Y_err return ddm.Solution(corr, err, m, cond)
def apply(self, solution): if self.diptype not in [1, 2, 3]: return solution corr = solution.corr err = solution.err m = solution.model cond = solution.conditions undec = solution.undec evolution = solution.evolution diptype = m.get_dependence("drift").diptype def set_dip_type(m, diptype): m.get_dependence("drift").diptype = diptype m.get_dependence("noise").diptype = diptype m.get_dependence("bound").diptype = diptype m.get_dependence("overlay").diptype = diptype set_dip_type(m, -1) ratio = get_detect_prob(cond['coherence'], self.detect) s = m.solve_numerical_implicit(conditions=cond, return_evolution=True) newcorr = corr * ratio + s.corr * (1 - ratio) newerr = err * ratio + s.err * (1 - ratio) newevo = evolution #newevo = evolution * ratio + s.evolution * (1-ratio) set_dip_type(m, diptype) return ddm.Solution(newcorr, newerr, m, cond, undec, newevo)
def apply(self, solution): # Make sure params are within range assert self.ndsigma > 0, 'Invalid st parameter' # Extract components of the solution object for convenience corr = solution.corr err = solution.err dt = solution.model.dt # Create the weights for different timepoints times = np.asarray(list(range(-len(corr), len(corr))))*dt weights = stats.norm(scale=self.ndsigma, loc=self.nondectime).pdf(times) if np.sum(weights) > 0: weights /= np.sum(weights) # Ensure it integrates to 1 newcorr = np.convolve(weights, corr, mode='full')[len(corr):(2*len(corr))] newerr = np.convolve(weights, err, mode='full')[len(corr):(2*len(corr))] return ddm.Solution(newcorr, newerr, solution.model, solution.conditions, solution.undec)
def solve(self, conditions={}, *args, **kwargs): corr = self.t_domain() * 0 err = self.t_domain() * 0 undec = self.x_domain(conditions=conditions) * 0 + 1 / len( self.x_domain(conditions=conditions)) return ddm.Solution(corr, err, self, conditions, undec)
def solve(self, conditions={}, *args, **kwargs): corr = self.t_domain() * 0 corr[1] = .8 err = self.t_domain() * 0 err[1] = .2 return ddm.Solution(corr, err, self, conditions)