def per_capita(place_vals, place_pop, factor=1):
  """Calculate per capital stats for each place.

  Args:
    place_vals: a dictionary mapping each place to an observed value.
    place_pop: a dictionary mapping each place to its population for some year.
    factor: number of people in the per capita denominator. Default 1.

  Returns:
    dictionary of place to observed value per <factor> people.
  """
  if factor:
    assert factor >= 1, 'Per capita factor must be greater than or equal to 1.'
  for dcid, val in place_pop.items():
    if val < 0:
      raise ValueError('Population is for %s is %s' % (dcid, val))
  place_vals = {
      dcid: factor * place_vals[dcid] / place_pop[dcid]
      for dcid in place_vals
  }
  return place_vals