Profilers

Typically, profilers are instantiated this way:

profile:
  # Specify the profiler class
  class: cosmofit.samplers.MinuitSampler
  init:
    # Any profiler option
    profiles: # optionally, profiles to resume from (e.g. to add 2D contours to)
    seed: None  # random seed
    max_tries: 1000  # maximum number of calls to get finite posterior
    # Normalize parameter by their variance, useful if parameters are of different orders of magnitude
    transform: False
    # If transform is True, covariance to normalize parameters
    # Can be previous samples ({fn: chain.npy, burnin: 0.5}), or profiles (containing covariance matrix)
    # If variance for a given parameter is not provided, use parameter 'proposal' squared
    covariance:
    ref_scale: 1.  # rescale all parameter reference distribution (from which they are initially sampled from) by this factor
  maximize:
    # Number of optimization runs, starting from independent points
    # Defaults to the number of MPI processes - 1
    niterations: None
  save: profiles.npy  # where to save profiles

One will typically run several independent likelihood maximizations in parallel, on number of MPI processes - 1 ranks (1 if single process), to make sure the global maximum is found. minuit profiler also allows to compute parameter’s interval (\(\Delta \chi^{2} = 1\)), 1D profiles and 2D contours; these calculations can be performed in parallel, for several parameters. In the following we present profilers’ default options (in addition to those presented above).

minuit

class: MinuitProfiler

info:
  version: 0.0.1
  date: 05/04/2022
  maintainer: Arnaud de Mattia
  description: Wrapper for minuit profiler
  url: https://github.com/scikit-hep/iminuit
  doi: [10.5281/zenodo.3949207, 10.1016/0010-4655(75)90039-9]
  long_description: Used by the high-energy physics community for likelihood profiling

init:

maximize:
interval:
  # Confidence level for the confidence interval.
  # If not set or None, a standard 68.3 % confidence interval is produced.
  # If 0 < cl < 1, the value is interpreted as the confidence level (a probability).
  # If cl >= 1, it is interpreted as number of standard deviations. For example, cl = 3 produces a 3 sigma interval.
  # cl: None
profile:
  # Number of scanning points. Ignored if grid is set.
  # size: 30
  # If bound is tuple, (left, right) scanning bound. If bound is a number, it specifies an interval of N sigmas
  # symmetrically around the minimum. Ignored if grid is set.
  # bound: 2
  # Parameter values on which to compute the profile. If grid is set, size and bound are ignored.
  # grid: None
contour:
  # Confidence level for the confidence interval.
  # If not set or None, a standard 68.3 % confidence interval is produced.
  # If 0 < cl < 1, the value is interpreted as the confidence level (a probability).
  # If cl >= 1, it is interpreted as number of standard deviations. For example, cl = 3 produces a 3 sigma interval.
  # cl: None
  # Number of points on the contour to find. Increasing this makes the contour smoother, but requires more computation time.
  # size: 100
  # Number of interpolated points on the contour. If you set this to a value larger than size,
  # cubic spline interpolation is used to generate a smoother curve and the interpolated coordinates are returned.
  # Values smaller than size are ignored. Good results can be obtained with size=20, interpolated=200.
  # interpolated: 0

bobyqa

class: BOBYQAProfiler

info:
  version: 0.0.1
  date: 05/04/2022
  maintainer: Arnaud de Mattia
  description: Wrapper for bobyqa profiler
  url: https://github.com/numericalalgorithmsgroup/pybobyqa
  doi: [10.48550/arXiv.1804.00154, 10.48550/arXiv.1812.11343]
  long_description: Designed for solving bound-constrained general objective minimization, without requiring derivatives of the objective.

init:

maximize:
  # The number of interpolation points to use; default is 2 * ndim + 1.
  # Py-BOBYQA requires ndim + 1 <= npt <= (ndim + 1)(ndim + 2)/2. Larger values are particularly useful for noisy problems.
  # npt: None
  # The initial value of the trust region radius default is 0.1 max(|x_0|_{\infty}, 1)`.
  # rhobeg: None
  # Minimum allowed value of trust region radius, which determines when a successful termination occurs.
  # rhoend: 1e-8
  # A flag to indicate whether to search for a global minimum, rather than a local minimum.
  # This is used to set some sensible default parameters, all of which can be overridden by the values provided in user_params.
  # If True, both upper and lower bounds must be set. Note that Py-BOBYQA only implements a heuristic method,
  # so there are no guarantees it will find a global minimum. However, by using this flag,
  # it is more likely to escape local minima if there are better values nearby.
  # The method used is a multiple restart mechanism, where we repeatedly re-initialize Py-BOBYQA from the best point found so far,
  # but where we use a larger trust reigon radius each time (note: this is different to more common multi-start approach to global optimization).
  # seek_global_minimum: False

scipy

class: ScipyProfiler

info:
  version: 0.0.1
  date: 05/04/2022
  maintainer: Arnaud de Mattia
  description: Wrapper for scipy profiler
  url: https://scipy.github.io/devdocs/reference/generated/scipy.optimize.minimize.html#scipy.optimize.minimize
  long_description: Collection of scipy's samplers

init:
  # Type of solver. Should be one of ‘Nelder-Mead’, ‘Powell’, ‘CG', ‘BFGS’, ‘Newton-CG’, L-BFGS-B’, ‘TNC’,
  # ‘COBYLA’, ‘SLSQP’ , ‘trust-constr’, ‘dogleg’, ‘trust-ncg’, ‘trust-exact’, ‘trust-krylov’
  # If not given, chosen to be one of BFGS, L-BFGS-B, SLSQP, depending on whether or not the problem has constraints or bounds.
  method: None

maximize:
  # Tolerance for termination. When tol is specified, the selected minimization algorithm sets some relevant solver-specific tolerance(s) equal to tol.
  # For detailed control, use solver-specific options.
  tol: None
  # Specific solver options