code: def conf_interval(
      minimizer,
      result,
      p_names=None,
      sigmas=None,
      trace=False,
      maxiter=200,
      verbose=False,
      prob_func=None,
  ):
      """Calculate the confidence interval (CI) for parameters.
  
      The parameter for which the CI is calculated will be varied, while the
      remaining parameters are re-optimized to minimize the chi-square. The
      resulting chi-square is used to calculate the probability with a given
      statistic (e.g., F-test). This function uses a 1d-rootfinder from SciPy
      to find the values resulting in the searched confidence region.
  
      Parameters
      ----------
      minimizer : Minimizer
          The minimizer to use, holding objective function.
      result : MinimizerResult
          The result of running minimize().
      p_names : list, optional
          Names of the parameters for which the CI is calculated. If None
          (default), the CI is calculated for every parameter.
      sigmas : list, optional
          The sigma-levels to find (default is [1, 2, 3]). See Notes below.
      trace : bool, optional
          Defaults to False; if True, each result of a probability
          calculation is saved along with the parameter. This can be used to
          plot so-called "profile traces".
      maxiter : int, optional
          Maximum of iteration to find an upper limit (default is 200).
      verbose : bool, optional
          Print extra debugging information (default is False).
      prob_func : None or callable, optional
          Function to calculate the probability from the optimized chi-square.
          Default is None and uses the built-in function `f_compare`
          (i.e., F-test).
  
      Returns
      -------
      output : dict
          A dictionary containing a list of ``(sigma, vals)``-tuples for
          each parameter.
      trace_dict : dict, optional
          Only if trace is True. Is a dictionary, the key is the parameter
          which was fixed. The values are again a dict with the names as
          keys, but with an additional key 'prob'. Each contains an array
          of the corresponding values.
  
      See Also
      --------
      conf_interval2d
  
      Notes
      -----
      The values for `sigma` are taken as the number of standard deviations
      for a normal distribution and converted to probabilities. That is, the
      default ``sigma=[1, 2, 3]`` will use probabilities of 0.6827, 0.9545,
      and 0.9973. If any of the sigma values is less than 1, that will be
      interpreted as a probability. That is, a value of 1 and 0.6827 will
      give the same results, within precision.
  
      Examples
      --------
      >>> from lmfit.printfuncs import *
      >>> mini = minimize(some_func, params)
      >>> mini.leastsq()
      True
      >>> report_errors(params)
      ... #report
      >>> ci = conf_interval(mini)
      >>> report_ci(ci)
      ... #report
  
      Now with quantiles for the sigmas and using the trace.
  
      >>> ci, trace = conf_interval(mini, sigmas=[0.5, 1, 2, 3], trace=True)
      >>> fixed = trace['para1']['para1']
      >>> free = trace['para1']['not_para1']
      >>> prob = trace['para1']['prob']
  
      This makes it possible to plot the dependence between free and fixed
      parameters.
  
      """
      if sigmas is None:
          sigmas = [1, 2, 3]
  
      ci = ConfidenceInterval(
          minimizer,
          result,
          p_names,
          prob_func,
          sigmas,
          trace,
          verbose,
          maxiter,
      )
      output = ci.calc_all_ci()
      if trace:
          return output, ci.trace_dict
      return output
  
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 4 for calling a global function with example usage: conf_interval(minimizer, result, p_names, sigmas, trace, maxiter, verbose, prob_func) and returns: output, output,  ci