Ways to call structure-based fit functions
chozo
Is there a way to use structure-based fit functions from the command line or by using Execute? I guess this is impossible. So the only other option to sneak in additional parameters / constants is either via global variables or global constants?
chozo -- .
The first thing that comes to mind is to use a wrapper function and call it from the command line. But I guess your inclusion of the Execute operation in your question shoots that one down?
Jeff
November 15, 2024 at 04:58 am - Permalink
Right- structures are only supported in user-defined functions, so the only way to use structure-based fit functions is to write a wrapper or driver function that sets up the structure and calls FuncFit. It really limits the usefulness of these fit functions, but it can be useful in a specialized fitting package aimed at some sort of fit that you need to do frequently. As you well know, Multipeak Fit package makes some use of structure fit functions.
One alternative to structure fit functions for passing in extra numeric information is to put the added info into the coefficient wave, and then hold the elements that contain constants. This is error-prone in that forgetting to hold such coefficients will almost certainly lead to a singular matrix error.
Your suggestion of using global variables is the other way to sneak in additional information. This is also error-prone, since the constants you set this way will persist. If they need to be customized to a particular data set, you have to remember to do that before running FuncFit.
November 15, 2024 at 09:33 am - Permalink
Thank you very much for your answers. I think a global variable is not so bad after all. But in my case, I realized I can circumvent this completely. I am building a fit function with a variable number of peaks (a 'MultiGauss' fit shape for my Super Quick Fit package), but in the end I just need to count the number of input coefficients to deduct the number of requested peaks. All good! In the future for more complicated cases, I may go the global string route after all, since this is most flexible. Super Quick Fit calls an initialization function anyway each time, so no issue with persistent globals in my case.
November 15, 2024 at 11:44 pm - Permalink