def get_ideological_topic_means(objective_topic_loc, 
                                objective_topic_scale,
                                ideological_topic_loc, 
                                ideological_topic_scale):
  """Returns neutral and ideological topics from variational parameters.
  
  For each (k,v), we want to evaluate E[beta_kv], E[beta_kv * exp(eta_kv)], 
  and E[beta_kv * exp(-eta_kv)], where the expectations are with respect to the 
  variational distributions. Like the paper, beta refers to the obective topic
  and eta refers to the ideological topic.
  
  Dropping the indices and denoting by mu_b the objective topic location and 
  sigma_b the objective topic scale, we have E[beta] = exp(mu + sigma_b^2 / 2),
  using the mean of a lognormal distribution.
  
  Denoting by mu_e the ideological topic location and sigma_e the ideological
  topic scale, we have E[beta * exp(eta)] = E[beta]E[exp(eta)] by the 
  mean-field assumption. exp(eta) is lognormal distributed, so E[exp(eta)] =
  exp(mu_e + sigma_e^2 / 2). Thus, E[beta * exp(eta)] = 
  exp(mu_b + mu_e + (sigma_b^2 + sigma_e^2) / 2).
  
  Finally, E[beta * exp(-eta)] = 
  exp(mu_b - mu_e + (sigma_b^2 + sigma_e^2) / 2).
  
  Because we only care about the orderings of topics, we can drop the exponents
  from the means.
  
  Args:
    objective_topic_loc: Variational lognormal location parameter for the 
      objective topic (beta). Should be shape [num_topics, num_words].
    objective_topic_scale: Variational lognormal scale parameter for the 
      objective topic (beta). Should be positive, with shape 
      [num_topics, num_words].
    ideological_topic_loc: Variational Gaussian location parameter for the 
      ideological topic (eta). Should be shape [num_topics, num_words].
    ideological_topic_scale: Variational Gaussian scale parameter for the 
      ideological topic (eta). Should be positive, with shape 
      [num_topics, num_words].
  
  Returns:
    neutral_mean: A matrix with shape [num_topics, num_words] denoting the
      variational mean for the neutral topics.
    positive_mean: A matrix with shape [num_topics, num_words], denoting the
      variational mean for the ideological topics with an ideal point of +1.
    negative_mean: A matrix with shape [num_topics, num_words], denoting the
      variational mean for the ideological topics with an ideal point of -1.
  """
  neutral_mean = objective_topic_loc + objective_topic_scale ** 2 / 2
  positive_mean = (objective_topic_loc + 
                   ideological_topic_loc + 
                   (objective_topic_scale ** 2 + 
                    ideological_topic_scale ** 2) / 2)
  negative_mean = (objective_topic_loc - 
                   ideological_topic_loc +
                   (objective_topic_scale ** 2 + 
                    ideological_topic_scale ** 2) / 2)
  return neutral_mean, positive_mean, negative_mean