In our research on the show Laughter, we came across Dr. Helen Pilcher's formula for writing hit British comedy.
x = (fl + no ) / p
where funniness (f) of the punchline times length of build-up (l) is added to the amount someone falls down (n) times the physical pain or social embarrassment (o for 'ouch'). All this is divided by the pun (p), which reduces laughter and produces more of a groan.
The story was picked up by Robert Siegel a while back.
Skeptics noted that the equation is not really based on any real research and see it as just another installation in the endless abyss of junk math including formulae for biscuit dunking and the perfect cup of tea.
I love spontaneity in my comedy, but I'm a sucker for slapstick too. Keep in mind Americans seem to differ from the British in their opinion of nasty jokes according to some recent studies. How do you take your humor?