The psychophysics of number arise from resource-limited spatial memory
People can identify the number of objects in small sets rapidly and without error but become increasingly noisy for larger sets. However, the cognitive mechanisms underlying these ubiquitous psychophysics are poorly understood. We present a model of a limited-capacity visual system optimized to individuate and remember the location of objects in a scene which gives rise to all key aspects of number psychophysics, including error-free small number perception and scalar variability for larger numbers. We therefore propose that number psychophysics can be understood as an emergent property of primitive perceptual mechanisms --- namely, the process of identifying and representing individual objects in a scene. To test our theory, we ran two experiments: a change-localization task to measure participants' memory for the locations of objects (Experiment 1) and a numerical estimation task (Experiment 2). Our model accounts well for participants' performance in both experiments, despite only being optimized to efficiently encode where objects are present in a scene. Our results demonstrate that the key psychophysical features of numerical cognition do not arise from separate modules or capacities specific to number, but rather from lower-level constraints on perception which are manifested even in non-numerical tasks.