parameters: (self, force_monte_carlo=False, force_1d_ei=False)
docstring: r"""Compute the expected improvement at ``points_to_sample``, with ``points_being_sampled`` concurrent points being sampled.
  
          .. Note:: These comments were copied from
            :meth:`moe.optimal_learning.python.interfaces.expected_improvement_interface.ExpectedImprovementInterface.compute_expected_improvement`.
  
          ``points_to_sample`` is the "q" and ``points_being_sampled`` is the "p" in q,p-EI.
  
          Computes the expected improvement ``EI(Xs) = E_n[[f^*_n(X) - min(f(Xs_1),...,f(Xs_m))]^+]``, where ``Xs``
          are potential points to sample (union of ``points_to_sample`` and ``points_being_sampled``) and ``X`` are
          already sampled points.  The ``^+`` indicates that the expression in the expectation evaluates to 0 if it
          is negative.  ``f^*(X)`` is the MINIMUM over all known function evaluations (``points_sampled_value``),
          whereas ``f(Xs)`` are *GP-predicted* function evaluations.
  
          In words, we are computing the expected improvement (over the current ``best_so_far``, best known
          objective function value) that would result from sampling (aka running new experiments) at
          ``points_to_sample`` with ``points_being_sampled`` concurrent/ongoing experiments.
  
          In general, the EI expression is complex and difficult to evaluate; hence we use Monte-Carlo simulation to approximate it.
          When faster (e.g., analytic) techniques are available, we will prefer them.
  
          The idea of the MC approach is to repeatedly sample at the union of ``points_to_sample`` and
          ``points_being_sampled``. This is analogous to gaussian_process_interface.sample_point_from_gp,
          but we sample ``num_union`` points at once:
          ``y = \mu + Lw``
          where ``\mu`` is the GP-mean, ``L`` is the ``chol_factor(GP-variance)`` and ``w`` is a vector
          of ``num_union`` draws from N(0, 1). Then:
          ``improvement_per_step = max(max(best_so_far - y), 0.0)``
          Observe that the inner ``max`` means only the smallest component of ``y`` contributes in each iteration.
          We compute the improvement over many random draws and average.
  
          :param force_monte_carlo: whether to force monte carlo evaluation (vs using fast/accurate analytic eval when possible)
          :type force_monte_carlo: bool
          :param force_1d_ei: whether to force using the 1EI method. Used for testing purposes only. Takes precedence when force_monte_carlo is also True
          :type force_1d_ei: bool
          :return: the expected improvement from sampling ``points_to_sample`` with ``points_being_sampled`` concurrent experiments
          :rtype: float64
docstring_summary: r"""Compute the expected improvement at ``points_to_sample``, with ``points_being_sampled`` concurrent points being sampled.
docstring_tokens: r Compute the expected improvement at points_to_sample with points_being_sampled concurrent points being sampled .
function: def compute_expected_improvement(self, force_monte_carlo=False, force_1d_ei=False):
          r"""Compute the expected improvement at ``points_to_sample``, with ``points_being_sampled`` concurrent points being sampled.
  
          .. Note:: These comments were copied from
            :meth:`moe.optimal_learning.python.interfaces.expected_improvement_interface.ExpectedImprovementInterface.compute_expected_improvement`.
  
          ``points_to_sample`` is the "q" and ``points_being_sampled`` is the "p" in q,p-EI.
  
          Computes the expected improvement ``EI(Xs) = E_n[[f^*_n(X) - min(f(Xs_1),...,f(Xs_m))]^+]``, where ``Xs``
          are potential points to sample (union of ``points_to_sample`` and ``points_being_sampled``) and ``X`` are
          already sampled points.  The ``^+`` indicates that the expression in the expectation evaluates to 0 if it
          is negative.  ``f^*(X)`` is the MINIMUM over all known function evaluations (``points_sampled_value``),
          whereas ``f(Xs)`` are *GP-predicted* function evaluations.
  
          In words, we are computing the expected improvement (over the current ``best_so_far``, best known
          objective function value) that would result from sampling (aka running new experiments) at
          ``points_to_sample`` with ``points_being_sampled`` concurrent/ongoing experiments.
  
          In general, the EI expression is complex and difficult to evaluate; hence we use Monte-Carlo simulation to approximate it.
          When faster (e.g., analytic) techniques are available, we will prefer them.
  
          The idea of the MC approach is to repeatedly sample at the union of ``points_to_sample`` and
          ``points_being_sampled``. This is analogous to gaussian_process_interface.sample_point_from_gp,
          but we sample ``num_union`` points at once:
          ``y = \mu + Lw``
          where ``\mu`` is the GP-mean, ``L`` is the ``chol_factor(GP-variance)`` and ``w`` is a vector
          of ``num_union`` draws from N(0, 1). Then:
          ``improvement_per_step = max(max(best_so_far - y), 0.0)``
          Observe that the inner ``max`` means only the smallest component of ``y`` contributes in each iteration.
          We compute the improvement over many random draws and average.
  
          :param force_monte_carlo: whether to force monte carlo evaluation (vs using fast/accurate analytic eval when possible)
          :type force_monte_carlo: bool
          :param force_1d_ei: whether to force using the 1EI method. Used for testing purposes only. Takes precedence when force_monte_carlo is also True
          :type force_1d_ei: bool
          :return: the expected improvement from sampling ``points_to_sample`` with ``points_being_sampled`` concurrent experiments
          :rtype: float64
  
          """
          num_points = self.num_to_sample + self.num_being_sampled
          union_of_points = numpy.reshape(numpy.append(self._points_to_sample, self._points_being_sampled), (num_points, self.dim))
  
          mu_star = self._gaussian_process.compute_mean_of_points(union_of_points)
          var_star = self._gaussian_process.compute_variance_of_points(union_of_points)
  
          if force_monte_carlo is False and force_1d_ei is False:
              var_star = numpy.fmax(MINIMUM_VARIANCE_EI, var_star)  # TODO(272): Check if this is needed.
              return self._compute_expected_improvement_qd_analytic(mu_star, var_star)
          elif force_1d_ei is True:
              var_star = numpy.fmax(MINIMUM_VARIANCE_EI, var_star)
              return self._compute_expected_improvement_1d_analytic(mu_star[0], var_star[0, 0])
          else:
              return self._compute_expected_improvement_monte_carlo(mu_star, var_star)
function_tokens: def compute_expected_improvement ( self , force_monte_carlo = False , force_1d_ei = False ) : num_points = self . num_to_sample + self . num_being_sampled union_of_points = numpy . reshape ( numpy . append ( self . _points_to_sample , self . _points_being_sampled ) , ( num_points , self . dim ) ) mu_star = self . _gaussian_process . compute_mean_of_points ( union_of_points ) var_star = self . _gaussian_process . compute_variance_of_points ( union_of_points ) if force_monte_carlo is False and force_1d_ei is False : var_star = numpy . fmax ( MINIMUM_VARIANCE_EI , var_star ) # TODO(272): Check if this is needed. return self . _compute_expected_improvement_qd_analytic ( mu_star , var_star ) elif force_1d_ei is True : var_star = numpy . fmax ( MINIMUM_VARIANCE_EI , var_star ) return self . _compute_expected_improvement_1d_analytic ( mu_star [ 0 ] , var_star [ 0 , 0 ] ) else : return self . _compute_expected_improvement_monte_carlo ( mu_star , var_star )