Fit

Fit [#] [Iterate #] Cause PLT to call the fitting routine to search for the best fitting parameters for the model specified with the "MOdel" command. The first optional number is the plot group to fit. If this number is omitted, then "Fit" will continue to fit the previous group that you were fitting if that plot group is still visible. For the first use of "Fit" or if the plot group has been "COlored OFf" then "Fit" will default to fitting the lowest numbered group which is visible. The "LAbel PArm" command controls whether the model parameters are plotted on the right side of the plot. Fitting continues until Delta chi^2 is less than 0.05. As a default, you will be prompted to continue fitting every 10 iterations. If you wish to increase the number of iterations without being prompted, then use the "Fit Iterate [#]". Thus, "Fit I 100", would allow the program to try up to 100 iterations before you would be prompted again.

Fit ON [#] Cause the current model to be plotted on group #. If # is omitted, the model will be plotted on plot group that was most recently fitted.

Fit OFf Cause the model to no longer be plotted.

Fit Plot # Control where the model is evaluated when it plotted. If # is greater than zero, then the model is evaluated at # points between the current x-scale Minimum and Maximum. If # is less than 0, then the model is evaluated at "ABS(#)" points between the Data Min and Data Max --- i.e., no extrapolation is allowed. If # equals 0, then the model is evaluated at the values of the data points. (This is the default.)

Fit Stat Chi|Ml # Set the default fitting statistic to either chi^2 or maximum likelihood. For example, "Fit Stat M 2" would vary the fit parameter to minimize the likelihood function when compared with plot group 2.

statistics

Prior to 1998 Oct, Fit Stat ML would minimize the likelihood function:

C = 2 * SUM{ model(i) - data(i)*ln(model(i)) + ln(data(i)!) }

where data(i) is the observed number of *counts* in the i'th bin and model(i) is the model evaluated at that location. Of course, data(i)! is the factorial. On 1998-Oct-01, the statistic was changed to:

C = 2 * SUM{ model(i) + data(i)*[ln(data(i))-ln(model(i))-1.] }

which is the same statistic as is now used by XSPEC (the famous John Castor "priv. comm." statistic). This differs from the likelihood function in terms that depend only upon the data. Since the goal is to find the minimum with respect to changes in the model parameters, this function will have the same minimum as the likelihood function. The advantage of this new function is that when you get a good fit, then C ~ DOF similar to chi^2. Of course, I would not suggest using a chi^2 table to interpret any results.

Prior to this change the "fit stat ml" would only work properly if you were fitting raw counts. If we assume that

rate(i) +/- sigma(i) = data(i)/E +/- SQRT(data(i))/E

where E is typically the exposure (area*time). Then it is easy to show that:

E = rate(i)/(sigma(i)^2)

(It is straightforward to handle the special case where data(i)=0.) Using this expression, the PLT version of CURFIT now scales the rate back into raw counts, and hence it is now possible to fit rates using "stat ml". If you accidently used "stat ml" with the old version, then don't worry, the main difference is the estimated parameter uncertainties, in the old version the estimate would be way off, and now they are approximately correct.

Finally, there is the case where the model goes to zero. There is no problem where the data(i) is also zero as C will evaluate to zero at that location. Formally speaking if the data<>0 then clearly there is a background term that should be included in the model (and if don't include the background then you really should not be fitting points where model=0). On the other hand, if the background level is low, for example, most of the counts are in a single gaussian shaped feature, then it is real tempting to model this with a single gaussian term and no background. If you tried this with the old version then you would discover that the gaussian width would slowly increase. This happened because it would result in fewer non-zero model bins and this would improve the statistic.

In the new version a model floor is defined. Thus if the model evalutates to less than the floor level, when calculating the statistic, the floor value is used. For now the floor value used is 1.0E-6 counts/bin. Thus if your model depends on seeing one (or fewer) count in a million bins, then this will result in a error or bias. On the other hand this does allow you to fit a narrow gaussian, no background and get a sensible result.


Return to plt main page.