gridlib.fit_grid

gridlib.fit_grid(parameters: Dict, data: Dict[str, Dict[str, ndarray]], disp: bool = True) Dict[str, Dict[str, Union[ndarray, float]]][source]

Functions performs the complete GRID fitting procedure on the provided survival time distribution data and returns the fit results.

Parameters
  • parameters (Dict) – Dictionary containing all the parameters needed to perform the GRID fitting.

  • data (Dict[str, Dict[str, np.ndarray]]) –

    A dictionary mapping keys (time-lapse conditions) to the corresponding time and value arrays of the survival functions. For example:

    {
        "0.05s": {
            "time": array([0.05, 0.1, 0.15, ...]),
            "value": array([1.000e+04, 8.464e+03, 7.396e+03, ...]),
        },
        "1s": {
            "time": array([1., 2., 3., 4., ...]),
            "value": array([1.000e+04, 6.925e+03, 5.541e+03, 4.756e+03, ...]),
        },
    }
    

  • disp (bool, optional) – If True, then messages and final minimization results are printed out, otherwise the there are no messages printed, by default True.

Returns

fit_results – A dictionary mapping keys (fitting procedure) to the corresponding fit results. For example:

{
    "grid": {
        "k": array([1.00000000e-03, 1.04737090e-03, ...]),
        "s": array([3.85818587e-17, 6.42847878e-18, ...]),
        "a": 0.010564217803906671,
        "loss": 0.004705659331508584,
    },
}

Return type

Dict[str, Dict[str, Union[np.ndarray, float]]]

Raises

ValueError – If an incorrect parameter value is provided or a value is missing.

Examples

Assume that the survival time distributions are stored in the variable data, so:

data = {...}
parameters = {
    "k_min": 10 ** (-3),
    "k_max": 10**1,
    "N": 200,
    "scale": "log",
    "reg_weight": 0.01,
    "fit_a": True,
    "a_fixed": None,
}
fit_results = fit_grid(parameters, data, disp=True)