function [data, labels] = generate_histories(choice_vector, method, analysis_window) % [DATA, LABELS] = generate_histories(CHOICE_VECTOR, METHOD, ANALYSIS_WINDOW) % % Converts an input choice vector into a set of history vectors (into DATA) % and switch/not-switch labels (into LABELS) % % Required: % CHOICE_VECTOR - The vector of choices given by the user (e.g. c1(:,1)') % % METHOD - Must be either 1, 2, or 3. Will specify the form of the reward % schedule presented under this trial % % ANALYSIS_WINDOW - The size of the reward history to use. For example, % if we want to include the past three rewards in the history vector, % then ANALYSIS_WINDOW will be 3. % % The output arguments are [DATA, LABELS]. DATA will contain the history % vectors and LABELS will contain the labels. % % Examples: % For the examples described in our project % % >> [train_data, train_labels]= generate_histories(c1(:,1)', 1, 5); reward_vector = play_game(choice_vector, method); for i=1:analysis_window, reward_histories(:, i) = [zeros(analysis_window-i+1,1); reward_vector(1:end+i-analysis_window-1)']; end; reward_histories = fliplr(reward_histories); labels = [0; abs(diff(choice_vector'))]; trial_num = 1:length(choice_vector); accum_rewards = cumsum(reward_vector); training_data = [labels reward_histories accum_rewards' trial_num']; data = training_data(analysis_window+1:end, 2:end); labels = training_data(analysis_window+1:end, 1);