For many animals, clumping is a survival strategy: with enough pandemonium, a hungry enemy, for instance, might become so disoriented that all members of the herd, flock or school could escape unscathed.
As Conor Myhrvold writes at Nautilus, humans, too, evolved this tendency to clump. In the distant past, this probably helped us fight off danger with the tried-and-true safety in numbers strategy. Today, however, those panicked reactions are misplaced. "In a room with six exits, it seems like the most logical course of action would be for the crowd to divide evenly among all six," Myhrvold writes. "Instead, we stampede to just one."
Just like people, ants tend to play follow-the-leader when presented with what they perceive to be mortal danger, such as some pesticide. Rather than stream evenly to two exists, Myhrvold explains, ants will favor a single exit—escaping more slowly than if they divided in half. When ant clumping is translated into mathematical formulas, scientists found that it mirrors human crowd dynamics.
These discoveries allowed researchers to stumble on a counterintuitive trick for hastening the escape of a crowd, whether ant or human: if an obstacle is placed in front of the exit, the flow of ants/people out the door quickens. Here's Nautilus with more on those surprising findings:
On average, it took 50 ants 18 seconds to get through an unobstructed mid-side exit. Adding a column in front of the mid-side exit reduced that time to 14 seconds. A corner exit with a column in front had an escape time of less than 11 seconds. But the best escape time was achieved with a corner exit without a column in front—less than 9.5 seconds.
These different streams of ants, or people, have to merge at the exit and take turns to pass. But people are impatient, and start pushing and shoving. Columns help structure the flow.
Of course, if you ever do find yourself in a stampede, resisting the herd mentality and bolting for the exit less noticed would likely be the most efficient way out.