function

zdm.optical_numerics.function(x, args)[source]

Objective function for scipy.optimize.minimize over host model parameters.

Updates the host magnitude model with parameter vector x, runs PATH on all FRBs, computes the chosen goodness-of-fit statistic, and returns a scalar value suitable for minimisation (i.e. smaller is better).

Parameters:
  • x (np.ndarray) – Parameter vector passed to model.init_args(x). Its meaning depends on the model (e.g. absolute magnitude bin weights for simple_host_model, or fSFR for loudas_model).

  • args (list) –

    Packed argument tuple with the following elements, in order:

    • frblist (list of str): TNS names of FRBs to evaluate.

    • ss (list of Survey): surveys in which the FRBs may appear.

    • gs (list of Grid): zdm grids corresponding to those surveys.

    • model: host magnitude model instance (must implement init_args).

    • POxcut (float or None): if not None, restrict the statistic to FRBs whose best host candidate has P(O|x) > POxcut.

    • istat (int): statistic to use — 0 for KS-like statistic, 1 for maximum-likelihood (returned as negative log-likelihood so that minimisation maximises the likelihood).

Returns:

stat – Goodness-of-fit statistic (smaller is better). For istat=1 this is the negative log-likelihood.

Return type:

float