  Ingroup favoritism, the tendency to favor ingroup over outgroup, is often
explained as a product of intergroup conflict, or correlations between group
tags and behavior. Such accounts assume that group membership is meaningful,
whereas human data show that ingroup favoritism occurs even when it confers no
advantage and groups are transparently arbitrary. Another possibility is that
ingroup favoritism arises due to perceptual biases like outgroup homogeneity,
the tendency for humans to have greater difficulty distinguishing outgroup
members than ingroup ones. We present a prisoner's dilemma model, where
individuals use Bayesian inference to learn how likely others are to cooperate,
and then act rationally to maximize expected utility. We show that, when such
individuals exhibit outgroup homogeneity bias, ingroup favoritism between
arbitrary groups arises through direct reciprocity. However, this outcome may
be mitigated by: (1) raising the benefits of cooperation, (2) increasing
population diversity, and (3) imposing a more restrictive social structure.
