This is Matlab code to accompany the journal paper "Using the past to estimate sensory uncertainty" by Beierholm+, Rohe+, Ferrari, Stegle and Noppeney. The main code for the computational models is located in the BayesianModel and ExponentialModel folders. The file exampleCode.m gives examples of how to run the model, researchers are free to use the optimizer/sampler that they prefer. The file allData.mat contains the data from the four data sequences across (25, 33, 19, 18) subjects. For any questions contact Ulrik Beierholm at Durham University, Psychology Department. The code for analysis of behavioral data and model predictions is located in the AnalysisScripts folder (i.e. AnalysisScript_Sin_RW1_RW2.m and AnalysisScript_SinJump.m). The file 'Raw data & model predictions...mat' contains raw behavioral data (including subjects which were excluded in the main analyses) and model predictions for the three computational models which were used for generating the figures. For questions on the analysis scripts, contact Tim Rohe at FAU Erlangen-Nuernberg, Institute of Psychology.