Skip to content

Commit dd89f96

Browse files
committed
started Figure 1 script edits
1 parent 151a17f commit dd89f96

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

Replicate_Figure1.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,22 @@
1515
TestData = pd.read_csv('data.csv')
1616

1717
# choose strategies to evaluate: subset shown in Figure 1
18+
strategies = ['go_left','go_right']
1819

20+
# set prior
1921
prior_type = 'Uniform' #set prior type
2022
decay_rate = 0.9
2123

2224
[alpha0, beta0] = set_priors(prior_type) # define priors
2325

2426
no_Trials = np.size(TestData.TrialIndex)
2527

26-
for rows in TestData.itertzuples():
27-
TestData.apply(go_right(TestData))
28+
Output = pd.DataFrame(columns = ['Alpha', 'Beta', 'MAPprobability', 'Precision']) # empty Dataframe to input data into
29+
30+
for trial in range(len(TestData)):
31+
32+
rows_of_data = TestData.iloc[0:trial+1] # select all rows of data up to the curren trial; is trial+1 as dataframe includes colu
33+
for index_strategy in range(len(strategies)):
34+
# run current strategy model on data up to current trial
35+
36+
# store results
0 Bytes
Binary file not shown.

strategy_models/go_right.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
# checks if the subject chose the left option on this trial
1+
# checks if the subject chose the right-hand option on this trial
22
# TYPE = GO_RIGHT(TRIAL_DATA) takes the Table of testdata TRIAL_DATA up to the current trial, and
33
# returns the TYPE ("success", 'failure')
4-
import pandas as pd
5-
64

75
# Checks only the current trial
86

9-
10-
def go_right(TestData):
11-
if TestData.Choice == "right":
7+
def go_right(rows):
8+
nTrials = len(rows);
9+
# "at" selects the value at the row/column location in the dataframe
10+
if rows.at[nTrials-1,'Choice'] == "right": # check the current trial's choice
1211
trial_type = "success"
13-
else:
12+
elif rows.at[nTrials-1,'Choice'] == "left":
1413
trial_type = "failure"
1514
return trial_type

0 commit comments

Comments
 (0)