Someone passed me a link to this really nice article, Annals of Science: The Eureka Hunt, which talks about how neuroscientists have been studying what goes on in the brain when we get those amazing ideas that seem to come from nowhere. In my own life I can think of several times where I've experienced a sudden "burst" of thought like this. Sometimes it seems like they exist for survival: i.e. unexpectedly losing my balance, about to slip, and my brain calculates every possible way I can catch myself before falling and does it all within 2ms. After the fact, I've wondered how that happened since it felt so involuntary. Then there's another type of brainwave phenomenon: one where you get a really great idea and you have no idea how it came to you. You'd be in the shower or staring out the window of the train on your way to work and—bam—something just hits you. Then you wonder, how the hell did I think of that?
If I understand the article correctly, this phenomenon is a function of the cortex: first the brain "charges" itself up (sort of like getting a shot of adrenallin) then the cortex relaxes so that all avenues to all regions of the brain are easily accessible. Or as the article puts it, "An insight is just a fleeting glimpse of the brain’s huge store of unknown knowledge."