When you're writing, you're putting thought into what you want to express, and then you come up with it - it comes to you. When you're improvising, it's the same thing. You're writing. You just say it out loud right then, instead of saying, 'You think this might work?'