Index
Many run single group fit
This is the flow of information in mujpy to produce the fit.
Back to Fit Types
Glossary:
- gr indicates a parameter that is global with respect to run. Note that this is not the same meaning as in [[Mujpy.C2|C2}} fits
- local indicates a parameter that varies with run (e.g. field or relaxation rates).
They are all dealt with by userpardicts lists.
The C1 fit is always preceded by a sequential B1 fit of the same group, to obtain optimized guesses of the local parameters.
In dashboard, a json file containing a dict,
- key "userpardicts_guess" contains a list of use inserted parameters, each a dict with keys
- "name", the parameter name
- "value", the initial guess
- "error", the initial step
- "flag", "~" or "!"
- limits, a list [maxvalue,minvalue] (json's null is automatically translated to None)
- key "model_guess" contains a list, in the order of their appearance in the model-name string, of
- component dicts, each with keys "name", component two letter name, "label", specific name suffix, "pardicts", a dict of
- parameter dicts, each with keys
- "name", standard parameter name,
- "value", guess value,
- "flag", "=" (the only admitted value)
- "function",
"p[k]"
or calculable expression in terms of p
, a Minuit parameter array
- "error_propagation", a string that evaluates as the error of this component parameter, as a function of Minuit parameters
p
and errors e
; typical example: amplitude as product of two Minuit parameters, fraction (p[0]
) and total asymmetry (p[1]
), the error string is "sqrt((e[0]*p[1])**2+(p[0]*e[1])**2)"
.
- "error", not used
- "limits", not used
The dashboard is modified in the code after the preliminary sequential B1 fit. This modification is not saved, in order to start always from a guess dashboard.
- First of all each parameters of the original "userpardicts_guess" list is identified by its index k.
Then a new key is added
- "userpardicts", containing an augmented list of user parameters, each a list of dicts (as many as the runs), so that each dict corresponds to a Minuit parameter.
- gr parameters correspond to a one-member list with the original dict
- local parameters get replicas, as many dict items as the number of runs. In each replica
- krun is the index of the replica
- the "value" item of the original pardict is updated to the corresponding best fit value of the B1 fit for this run.
- nmin is the index of this local parameter in the Minuit list
- a "function" key is added to each pardict, with string "p["+str(nmin)+"]"
- the "function" key of the corresponding "model_guess" parameters is set to empty string, "". these parameters are identified as all those whose "function" is equal to the simple string "p["+str(k)+"]" (local parameters cannot be linear functions of several Minuit parameters)
The general rule for parameter evaluation, implemented by int2_multigroup_multirun_method_key, is simple
- the model is scanned and a list of lists of lists of function strings is produced
- for each G parameter, recognized by a function
The rest has to be implemented
For example model "mgml" contains two components, "mg", a Gaussian-relaxing precession, and "ml" a Lorentzian-relaxing precession, each with four parameters. If "mg" "label" is "_fast", its parameters have "_fast" appended to their names.
aux int2min_multigroup_multirun produces the Minuit list of guess parameter values by scanning the model components, in the order in which they appear in "mgml". It
- scans the "userpardicts" list, looking for lists of len>1; e.g. "B", for each k-th item it produces a replica "B", unique name "B_"+str(k)
- parameters with key "function_multi" are already taken care of by the userpars they refer to.
aux int2_multigroup_multirun_method_key takes care of passing the right parameter to the right component method. It produces a list of [method, keys], one per method, where
- method is the python function from mucomponents mumodel that calculates the component, as in
f = method(t,*argv)
, where t is the 1-d time array, argv is a list of the dashboard parameter values for that component, and f is an array with the same shape as t
- argv is calculated as
[eval(key) for key in keys]
, therefore key is a string like "p[3]" (assuming that p
is the array of parameter values passed by Minuit at this iteration)
aux min2int translates back best fit values to component parameters
mumodel _load_data_multigroup_multirun_ preloads 1-d time, 3-d asymmetry and 3-d asymmetry errors, methods and key lists.
mumodel _chisquare_ is the cost function; the same works also for multidimensional asymmetries, because np.sum adds by default over all dimensions.
mumodel _add_multigroup_multirun_ assigns the correct parameters to each component, calculated from the Minuit array of parameters. It must produce a three dimensional f function, with as many bins as time, as many groups and runs as asymmetry
the_model._load_data_(time,asymmetry,...)
,
m = Minuit(the_model._chisquare_,names,*values)
m.errors = errors
, etc
m.migrad()
Minuit migrad()
method calls
the_model._chisquare_
, which in turns calls
the_model._add_multigroup_multirun_(x,*argv)
, where argv
is the Minuit array of parameters. Their assignment to component methods is performed
- scanning the method list
- scanning the keys list of each method and evaluating each key
Back to Fit Types
Index