a, Distribution of gains between accumulated walking rotation and accumulated PVA estimate for flies walking in the dark before exposure to visual stimulus in closed-loop experiment (mean = 0.47 ± 1.2, n = 397 walking bouts). b, Distribution of gains between accumulated walking rotation and PVA estimate of flies walking with a bright stripe with high (light red, mean = 0.86 ± 0.64, n = 147 walking bouts) or low (light blue, mean = 0.54 ± 0.5, n = 132) closed-loop gain. All gains used were close to the likely ‘natural’ gain. c, Distribution of gains between accumulated walking rotation and PVA estimate of flies walking in darkness after walking with a stripe under closed-loop control in high (red, mean = 0.57 ± 0.84, n = 150) or low (blue, mean = 0.46 ± 0.7, n = 134) gain conditions. d, Distribution of correlation coefficients between accumulated walking rotation and accumulated PVA estimate for flies walking in darkness before visual experience in the closed-loop setup (mean = 0.6 ± 0.42). e, Distribution of correlation coefficients between accumulated walking rotation and accumulated PVA estimate for flies walking with a stripe under closed-loop control with high (light red, mean = 0.79 ± 0.34) or low (light blue, mean = 0.85 ± 0.18) closed-loop gain. f, Distribution of correlation coefficients between accumulated walking rotation and accumulated PVA estimate for flies walking in darkness after walking with a stripe under closed-loop control with high (red, mean = 0.48 ± 0.43) or low (blue, mean = 0.49 ± 0.49) gain. P values (Kolmogorov–Smirnov two-sample test) for tests of the null hypothesis that the correlations from two different conditions are drawn from the same distribution are as follows. The null hypothesis can be rejected at P < 0.05 for: gain DarkAfterHighGain vs gain DarkAfterLowGain : P = 0.04; gain DarkNaive vs gain DarkAfterHighGain : P = 0.01; gain StripeHighGain vs gain StripeLowGain : P = 4 × 10−8; gain StripeHighGain vs gain DarkAfterHighGain : P = 3 × 10−7; gain StripeLowGain vs gain DarkAfterLowGain : P = 0.05; gain StripeLowGain vs gain DarkNaive : P = 0.001; gain StripeHighGain vs gain DarkNaive : P = 1 × 10−15. It cannot be rejected for: gain DarkNaive vs gain DarkAfterLowGain : P = 0.2. Subscripts indicate conditions of the relevant experiments. DarkNaive: in darkness without previous exposure to closed-loop visual stimulus; DarkAfterLowGain: walking in darkness after a period of walking in closed loop with a single-stripe stimulus under low closed-loop gain conditions; DarkAfterHighGain: walking in darkness after a period of walking in closed loop with a single-stripe stimulus under high closed-loop gain conditions; StripeHighGain: walking with a single stripe under high closed-loop gain; StripeLowGain: walking with a single stripe under low closed-loop gain.