Computational principles of collective decision making