According to Matt Damon's commentary on the DVD, Robin Williams improvised the line about his character's wife farting in bed. The comment caught everyone so off guard that you can see the camera shaking from laughter during the scene.