Why and how the brain weights contributions from a mixture of experts