示例#1
0
    def __init__(self, n, alphas, TR=2, ISI=2, prng=None):
        try:
            Exp.__init__(self, TR=2, ISI=2, prng=None)
        except AttributeError:
            pass

        self.prng = process_prng(prng)

        # Simulate a learning task and acc.
        ncond = 1
        trials, acc, p, self.prng = simBehave.behave.learn(ncond, n, 3, True, self.prng)

        # And hand the results off of self
        self.trials = np.array(trials)
        self.durations = np.array([1] * len(self.trials))

        # Or add them to the data attr
        self.data["ncond"] = ncond
        self.data["acc"] = acc
        self.data["p"] = p

        # Run the RL sim, and save the results keying (partly)
        # off of alpha an alpha counter
        for ii, alpha in enumerate(alphas):
            v_dict, rpe_dict = rl.reinforce.b_delta(acc, trials, alpha)
            values = rl.misc.unpack(v_dict, trials)
            rpes = rl.misc.unpack(rpe_dict, trials)

            self.data["value" + str(ii)] = values
            self.data["rpe" + str(ii)] = rpes

        self.data["alphas"] = alphas

        # Create random data too.
        self.data["rand"] = self.prng.rand(n)
示例#2
0
 def __init__(self, n, TR=2, ISI=2, prng=None):
     try: 
         Exp.__init__(self, TR=2, ISI=2, prng=None)
     except AttributeError: 
         pass
     
     self.prng = process_prng(prng)
     
     self.trials = np.array([0,]*n + [1,]*n)
     self.durations = [1, ] * len(self.trials)
     
     self.prng.shuffle(self.trials)
示例#3
0
 def __init__(self, n, TR=2, ISI=2, prng=None):
     try: 
         Exp.__init__(self, TR=2, ISI=2, prng=None)
     except AttributeError: 
         pass
     
     self.prng = process_prng(prng)
     
     # event_random(N,k,mult=1)
     self.trials, self.prng = event_random(2, n, 1, self.prng)
     self.trials = np.array(self.trials)
     
     self.durations = [1, ] * len(self.trials)
示例#4
0
    def __init__(self, n, n_cond=2, TR=2, durations=None,):
        try:
            Exp.__init__(self, TR=TR, ISI=2, prng=None)
        except AttributeError:
            pass

        self.trials, self.prng = event_random(n_cond, n, 1, self.prng)
        self.trials = np.array(self.trials)
        if durations != None:
            start, stop = durations[0], durations[1]
            self.durations = [random_integers(start, stop) for 
                    _ in self.trials]
        else:
            self.durations = [1, ] * len(self.trials)
示例#5
0
 def __init__(self, n, behave='learn', TR=2, ISI=2, prng=None):
     try: 
         Exp.__init__(self, TR=2, ISI=2, prng=None)
     except AttributeError: 
         pass
     
     self.prng = process_prng(prng)
     
     n_cond = 1
     n_trials_cond = n
     trials = []
     acc = []
     p = []
     if behave == 'learn':
 		trials, acc, p, self.prng = simBehave.behave.learn(
 				n_cond, n_trials_cond, 3, True, self.prng)
     elif behave == 'random':
 			trials, acc, p, self.prng = simBehave.behave.random(
                     n_cond,n_trials_cond, 3, self.prng)
     else:
         raise ValueError(
                 '{0} is not known.  Try learn or random.'.format(behave))
     
     # Find best RL learning parameters for the behavoiral data
     # then generate the final data and unpack it into a list.
     best_rl_pars, best_logL = rl.fit.ml_delta(acc, trials, 0.05)
     v_dict, rpe_dict = rl.reinforce.b_delta(acc, trials, best_rl_pars[0])
     values = rl.misc.unpack(v_dict, trials)
     rpes = rl.misc.unpack(rpe_dict, trials)
     
     # Store the results in appropriate places
     self.trials = np.array(trials)
     self.durations = np.array([1, ] * len(self.trials))
     self.data['acc'] = acc
     self.data['p'] = p
     self.data['best_logL'] = best_logL
     self.data['best_rl_pars'] = best_rl_pars
     self.data['value'] = values
     self.data['rpe'] = rpes
     self.data['rand'] = self.prng.rand(len(self.trials))
示例#6
0
    def __init__(
        self,
        n,
        n_cond=2,
        TR=2,
        durations=None,
    ):
        try:
            Exp.__init__(self, TR=TR, ISI=2, prng=None)
        except AttributeError:
            pass

        self.trials, self.prng = event_random(n_cond, n, 1, self.prng)
        self.trials = np.array(self.trials)
        if durations != None:
            start, stop = durations[0], durations[1]
            self.durations = [
                random_integers(start, stop) for _ in self.trials
            ]
        else:
            self.durations = [
                1,
            ] * len(self.trials)