code: def logEI_gaussian(mean, var, thresh):
      """Return log(EI(mean, var, thresh))
  
      This formula avoids underflow in cdf for
          thresh >= mean + 37 * sqrt(var)
  
      """
      assert np.asarray(var).min() >= 0
      sigma = np.sqrt(var)
      score = old_div((mean - thresh), sigma)
      n = scipy.stats.norm
      try:
          float(mean)
          is_scalar = True
      except TypeError:
          is_scalar = False
  
      if is_scalar:
          if score < 0:
              pdf = n.logpdf(score)
              r = np.exp(np.log(-score) + n.logcdf(score) - pdf)
              rval = np.log(sigma) + pdf + np.log1p(-r)
              if not np.isfinite(rval):
                  return -np.inf
              else:
                  return rval
          else:
              return np.log(sigma) + np.log(
                  score * n.cdf(score) + n.pdf(score)
              )
      else:
          score = np.asarray(score)
          rval = np.zeros_like(score)
  
          olderr = np.seterr(all="ignore")
          try:
              negs = score < 0
              nonnegs = np.logical_not(negs)
              negs_score = score[negs]
              negs_pdf = n.logpdf(negs_score)
              r = np.exp(
                  np.log(-negs_score) + n.logcdf(negs_score) - negs_pdf
              )
              rval[negs] = np.log(sigma[negs]) + negs_pdf + np.log1p(-r)
              nonnegs_score = score[nonnegs]
              rval[nonnegs] = np.log(sigma[nonnegs]) + np.log(
                  nonnegs_score * n.cdf(nonnegs_score)
                  + n.pdf(nonnegs_score)
              )
              rval[np.logical_not(np.isfinite(rval))] = -np.inf
          finally:
              np.seterr(**olderr)
          return rval
  
file_path: auptimizer/src/aup/Proposer/hyperopt/criteria.py
imports: from __future__ import division
  from past.utils import old_div
  import numpy
  import scipy.stats
label_desc: Use image node_id 4 for calling a global function with example usage: logEI_gaussian(mean, var, thresh) and returns: rval, unknown, unknown, rval