Code and data to accompany: 
Risk preferences depend on environmental richness in rats performing a patch-foraging task (Garcia & Wikenheiser)

Lead contact: Andrew Wikenheiser (amwikenheiser@psych.ucla.edu)

The 'data' folder contains raw behavioral data for all sessions in a .mat file.

The 'code' folder contains custom code needed to reproduce all figures and analysis in the manuscript. The function 'patch_risk_runEverything.m' steps through the entire analysis, going from raw data to the figures and statistics reported in the manuscript. The numerical simulations are somewhat slow to run, so the optimal patch residence times determined this way are included as hard-coded variables in the ...runEverything file. You can also comment out the simulation block to determine these values yourself.

Our code relies on several freely-available packages; locations are listed below. These must be saved to a location on MATLAB's path to run the analyses described above.

MClust (https://www.mathworks.com/matlabcentral/fileexchange/72128-mclust)
Distinguishable colors (https://www.mathworks.com/matlabcentral/fileexchange/29702-generate-maximally-perceptually-distinct-colors)
plotSpread (https://www.mathworks.com/matlabcentral/fileexchange/37105-plot-spread-points-beeswarm-plot)
chronux (http://chronux.org/)
Circle (https://www.mathworks.com/matlabcentral/fileexchange/2876-draw-a-circle)
redblue (https://www.mathworks.com/matlabcentral/fileexchange/25536-red-blue-colormap)
smooth2a (https://www.mathworks.com/matlabcentral/fileexchange/23287-smooth2a)

