Frequent Flyer, Business Traveler, or Terrorist?

Rather, how is a passenger judged by security personnel at an airport checkpoint, and how do security personnel arrive at their conclusion? Is a logical and foolproof method being used, or is it simply random guessing with no basis whatsoever — or perhaps the criteria is somewhere in between?