A computational model of confidence generation. A, The sensory signal (rsens) available at the decision level is read out (rreadout) to the metacognitive level and additional noise (σmeta) is added before obtaining the confidence signal (rmeta). The perceptual decision is based on the sensory signal rsens, whereas the confidence judgment is based on the confidence signal rmeta. Consistent with the hypothesized roles of DLPFC and aPFC in confidence computation, we modeled the effect of DLPFC TMS as a signal loss from the readout (quantified as Δrsens; boxed equation on the left) and the effect of aPFC TMS as lowered metacognitive noise (quantified as Δσmeta; boxed equation on the right). B, C, Model simulations show that decreasing the magnitude of the readout decreases the overall confidence level (B), but does not influence metacognitive ability (C). Conversely, decreasing the amount of metacognitive noise in the second half of test blocks has a small effect on average confidence (B), but a large effect on increasing the difference in metacognitive ability between the first and second half of blocks (C). These results mirror the effects of TMS to DLPFC and aPFC in our data (see Figs. 3 and 4).