A central question in neuroscience is how context changes perception of sensory stimuli. In the olfactory system, for example, experiments show that task demands can drive merging and separation of cortical odor responses, which underpin olfactory generalization and discrimination. Here, we propose a simple statistical mechanism for this effect, based on unstructured feedback from the central brain to the olfactory bulb, representing the context associated with an odor, and sufficiently selective cortical gating of sensory inputs. Strikingly, the model predicts that both pattern separation and completion should increase when odors are initially more similar, an effect reported in recent experiments. The theory predicts reversals of these trends following experimental manipulations and neurological conditions such as Alzheimer’s disease that increase cortical excitability.