Attached is a functional program that performs a fit as I would like. I nonetheless have a question about using ‘SetParameter’ and ‘FixParameter’. If I use ‘SetParameters’ to initialize my parameters in my ‘main()’ function and they are propagated into various other auxiliary functions, should they be fixed in these auxilary functions using ‘FixParameters’ or should they be further propagated using ‘SetParameters’.
Instinctively, I feel that the parameters are only free in the ‘main()’ function and in the auxiliary function they should be considered fixed, as I have done in my program, but I am not completely sure. test6MV_alpha_strydom_frm.c (6.9 KB)
Thanks @Vpadulan. But to try to home in a little more on my question, should I also fix the parameters ‘d50’, ‘a’, ‘A’ using FixParameters? In my main() function they are left as free parameters, but what should happen in the auxiliary functions. Should they be left free there as well?
That really depends on your analysis. Do you know a priori that those parameters should have a fixed value? Or are they uncertain? You should then use FixParameter or SetParameter respectively
the section called “Setting initial conditions” available here explains the difference. The TF1::SetParameters(...) merely initializes the parameters to some values, but it does not fix them in any way - they can still vary freely in both directions starting from the initial value.
The TF1::FixParameter(...), however, fixes the parameter, and it can no longer vary freely.
True, but it also fixes the parameter later on by setting both lower and upper limits on its possible range to the same value (see lines 1567 and 1568).
I agree. It’s not necessary to set the initial values of those parameters you are willing to fix.
Are you talking about fixing them for this fit: graph->Fit("alpha", "R");
? If so, probably not: if you fix all seven of your fit parameters, why do you need the fit in the first place?
Thanks @yus and @vpadulan for your replies. I work in a group in which I am the only Root user so this forum is a lifeline to me. I see that I did not completely manage to make my question clear and the answers have so far dealt with a side issue which is a redundancy in my code.
I understand that in ‘main()’ function the parameters that I wish to be determined by the fit should be initialized using ‘SetParameter’ while the remaining parameters should be fixed using ‘FixParameter’. I also understand that ‘FixParameter’ calls ‘SetParameter’ so that while it is harmless to first use the latter before the former on a fixed parameter there is no real need to. I have removed this ambiguity from the ‘alpha_shab()’ function to try to get to the heart of my question.
I am asking about should happen in auxiliary functions. I have attached two sample codes to try to illustrate my point. In the ‘main()’ function my free parameters are ‘d50’, ‘A’ and ‘a’ which are then propagated into the function ‘alpha_shab()’ and then propagated into several other functions. As far as I can tell, it makes no difference whether in ‘alpha_shab()’ and these additional functions, I apply ‘FixParameter’ or ‘SetParameter’. It only matters how I apply ‘FixParameter’ and SetParameter’ in my ‘main()’ function. Is this correct?