The invention of the cotton gin was the result of necessity and observation.