To analyze LAT data, we construct the likelihood that is applicable to the LAT data, and then use this likelihood to find the best fit model parameters. These parameters include the description of a source's spectrum, its position, and even whether it exists.

The likelihood *L* is the probability of obtaining the data given an input model. In our case, the input model is the distribution of gamma-ray sources on the sky, and includes their intensity and spectra. There is an implicit assumption that we understand sufficiently well the response of our detectors, in this case the LAT and the GBM, to the incident flux, in other words, that we have a sufficiently accurate mapping of the input model (the gamma-ray sky) to the data (the list of counts produced by either the LAT or the GBM).

Clearly, we expect a higher probability of obtaining the data from a model that is a better description of the underlying reality than from a model that is a poor description. At the same time we need to consider the plausibility of the models being compared; the data must favor a less plausible model more strongly before we accept that model. For example, few would consider a 30 percent discrepancy between energies calculated in an undergraduate laboratory course to be evidence for a violation of the conservation of energy.

The form of the LAT likelihood function will be discussed in the next section.

In one of the most common applications, we know that a source is present, and we want to determine the best value of the spectral model parameters. Since we expect the best model to have the highest probability of resulting in the data, we vary the spectral parameters until the likelihood is maximized. Note that χ^{2} is -2 times the logarithm of the likelihood in the limit of a large number of counts in each bin, and therefore where χ^{2} is a valid statistic, minimizing χ^{2} is equivalent to maximizing the likelihood.

A number of steps are necessary to fit a source's spectra; these are described in detail below.

- Select the data. The data from a substantial spatial region around the source(s) being analyzed must be used because of the overlapping of the point spread functions of nearby sources.
- Select the model. This model includes the position of the source(s) being analyzed, the position of nearby sources, a model of the diffuse emission, the functional form of the source spectra, and values of the spectral parameters. In fitting the source(s) of interest, you will let the parameters for these sources vary, but because the region around these sources includes counts from nearby sources in which you are not interested, you might also let the parameters from these nearby sources vary.
- Precompute a number of quantities that are part of the likelihood computation. As the parameter values are varied in searching for the best fit, the likelihood is calculated many times. While not strictly necessary, precomputing a number of computation-intensive quantities will greatly speed up the fitting process.
- Finally, perform the actual fit. The parameter space can be quite large—the spectral parameters from a number of sources must be fit simultaneously—and therefore the likelihood tools provide a choice of three 'optimizers' (section 7.8) to maximize the likelihood efficiently. Fitting requires repeatedly calculating the likelihood for different trial parameter sets until a value sufficiently near the maximum is found; the optimizers guide the choice of new trial parameter sets to converge efficiently on the best set. The variation of the likelihood in the vicinity of the maximum can be related to the uncertainties on the parameters, and therefore these optimizers estimate the parameter uncertainties.

Thus likelihood spectral fitting provides the best fit parameter values and their uncertainties. But is this a good fit? When χ^{2} is a valid statistic, then we know that the value of χ^{2} is drawn from a known distribution, and we can use the probability of obtaining the observed value as a goodness-of-fit measure. When there are many degrees of freedom (i.e., the number of energy channels minus the number of fitted parameters) then we expect the χ^{2} per degree of freedom to be ~1 for a good fit. However, when χ^{2} is not a valid statistic, we usually do not know the distribution from which the maximum likelihood value is drawn, and therefore we do not have a goodness-of-fit measure.

As mentioned above, the optimizers find the best fit spectral parameters, but not the location. In other words, the fitting tool does not fit the source coordinates. However, a tool is provided that performs a grid search—mapping out the maximum likelihood value over a grid of locations. As will be explained below, it is convenient to use a quantity called the 'Test Statistic' TS that is maximized when the likelihood is maximized.

The Test Statistic is defined as TS=-2ln(*L _{max,0}/L_{max,1}*), where

» Forward to The Likelihood Functional Form

» Back to The Challenge of LAT Data Analysis

» Back to the beginning of the likelihood section

» Back to the beginning of the Cicerone