mySession.loc[:, 'abs_stim'] = abs(mySession.loc[:, 'stim'] - stim_set.mean()) mySession.loc[:, 'percept'] = mySession.stim + np.random.randn( nTrials) * stim_noise mySession.loc[:, 'feedbackTime'] = np.random.exponential(Beta, nTrials) mySession.loc[:, ['isChoiceLeft', 'isCorrect', 'isCatch', 'isRewarded']] = False mySession.loc[:, 'isCatch'] = np.random.rand(nTrials) < pCatch #%% Initialization mySession.loc[0, 'rho'] = 4 mySession.loc[0, 'beta'] = 1.5 mySession.loc[0, 'boundary'] = .5 mySession.loc[0, 'slope'] = 1 b = stim_set.mean() Phi = makephi(m=10, nTimeBins=50, isNormalized=True, maxT=20) Theta = pd.DataFrame(index=Phi.index, columns=stim_set) if False: # initialize all Theta_of_x to the same random vector temp = np.random.randn(Theta.shape[0]) + 1 for i in range(Theta.shape[1]): Theta.iloc[:, i] = temp elif False: Theta.loc[:, :] = np.random.randn(Theta.shape[0], Theta.shape[1]) elif True: Theta.loc[:, :] = 1 elif False: if os.path.isfile('Theta.pickle'): with open('Theta.pickle', 'rb') as fhandle: Theta = pickle.load(fhandle)
import sys import os import pandas as pd import numpy as np import matplotlib.pyplot as plt import sklearn as sk from sklearn import preprocessing as skp import seaborn as sns from locallib import makephi, pnorm, truncExp sys.version # %% tbf = makephi(m=10, T=20, isNormalized=True) plt.figure(figsize=(4, 6)) plt.subplot(211) plt.imshow(tbf, aspect='auto') plt.colorbar() plt.subplot(212) plt.plot(tbf.T, alpha=.8) plt.show() np.random.seed(42) pass #%% PARAMS nTrials = 10000 learnRateWait = .1