class_docstr: Class used to calculate the confidence interval.
class_docstr_tok: ["Class","used","to","calculate","the","confidence","interval","."]
docstr: Calculate the CI for a single parameter in a single direction.
  
  Direction is either positive or negative 1.
docstr_tok: ["Calculate","the","CI","for","a","single","parameter","in","a","single","direction",".","Direction","is","either","positive","or","negative","1","."]
code: def calc_ci(self, para, direction):
      """Calculate the CI for a single parameter in a single direction.
  
      Direction is either positive or negative 1.
  
      """
      if isinstance(para, str):
          para = self.params[para]
  
      # function used to calculate the probability
      cache = {}
  
      def calc_prob(val, target_prob):
          if val not in cache:
              cache[val] = self.calc_prob(para, val, 0)
          return cache[val] - target_prob
  
      if self.trace:
          x = [i.value for i in self.params.values()]
          self.trace_dict[para.name].append(x + [0])
  
      para.vary = False
      limit, max_prob = self.find_limit(para, direction)
      a_limit = float(para.value)
      ret = []
      orig_warn_settings = np.geterr()
      np.seterr(all="ignore")
      for prob in self.probs:
          if prob > max_prob:
              ret.append((prob, direction * np.inf))
              continue
  
          sol = root_scalar(
              calc_prob,
              method="toms748",
              bracket=sorted([limit, a_limit]),
              rtol=0.5e-4,
              args=(prob,),
          )
          if sol.converged:
              val = sol.root
          else:
              val = np.nan
              break
          a_limit = val
          ret.append((prob, val))
  
      para.vary = True
      self.reset_vals()
      np.seterr(**orig_warn_settings)
      return ret
  
file_path: lmfit-py/lmfit/confidence.py
imports: from warnings import warn
  import numpy
  from scipy.optimize import root_scalar
  from scipy.special import erf
  from scipy.stats import f
  from .minimizer import MinimizerException
label_desc: Use image node_id 3 for calling the ConfidenceInterval obj's underlying member method code with example usage: obj.calc_ci(para, direction) and returns: ret, unknown