Commit 392384d8dff71337f4f2edea9729fd5ad2c3698a

Authored by Jürgen Knödlseder
1 parent 1d70cb14

Add section on maximum likelihood estimation to User Manual

doc/source/users/user_manual/index.rst
... ... @@ -8,6 +8,7 @@ User Manual
8 8  
9 9 introduction
10 10 data
  11 + likelihood
11 12 models
12 13 response
13 14  
... ...
doc/source/users/user_manual/likelihood.rst 0 → 100755
  1 +.. _um_likelihood:
  2 +
  3 +Maximum likelihood estimation
  4 +-----------------------------
  5 +
  6 +The central method behind the ctools data analysis is the maximum likelihood
  7 +estimation of the parameters of a given :ref:`model <um_models>`. The method
  8 +obtains the parameter estimates by finding the parameter values that maximize
  9 +the likelihood function :math:`L(M)`. The likelihood function quantifies the
  10 +probability that the data are drawn from a particular :ref:`model <um_models>`
  11 +:math:`M`. The formulae used for the likelihood computation depends on whether
  12 +the data are unbinned or binned and on the assumed underlying statistical law.
  13 +An iterative Levenberg-Marquardt algorithm is employed for maximum likelihood
  14 +estimation.
  15 +
  16 +
  17 +Unbinned data
  18 +~~~~~~~~~~~~~
  19 +
  20 +For unbinned data the Poisson formula
  21 +
  22 +.. math::
  23 + -\ln L(M) = E(M) - \sum_i \ln P(p'_i, E'_i ,t'_i | M)
  24 +
  25 +is used, where the sum is taken over all events :math:`i`, characterised by the
  26 +instrument direction :math:`p'_i`, the measured energy :math:`E'_i`
  27 +and the trigger time :math:`t'_i`. :math:`P(p', E' ,t' | M)` is
  28 +the probability density that given the :ref:`model <um_models>` :math:`M`, an
  29 +event with instrument direction :math:`p'`, measured energy :math:`E'`
  30 +and trigger time :math:`t'` occurs. :math:`E(M)` is the total number of events
  31 +that are predicted to occur during an observation given the
  32 +:ref:`model <um_models>` :math:`M`, computed by integrating the probability
  33 +density over the trigger time, measured energy and instrument direction:
  34 +
  35 +.. math::
  36 + E(M) = \int_{GTI} \int_{Ebounds} \int_{ROI} P(p',E',t' | M) \,
  37 + d\vec{p}' \, dE' \, dt'
  38 +
  39 +The temporal integration boundaries are defined by the Good Time Intervals
  40 +(GTIs) that define contiguous periods in time during which data were taken.
  41 +The spatial integration boundaries are defined by a so-called Region of
  42 +Interest (ROI).
  43 +
  44 +
  45 +Binned data
  46 +~~~~~~~~~~~
  47 +
  48 +For binned data following a Poisson distribution the formula
  49 +
  50 +.. math::
  51 + -\ln L(M) = \sum_i e_i(M) - n_i \ln e_i(M)
  52 +
  53 +is used, where the sum over :math:`i` is now taken over all data cube bins.
  54 +:math:`n_i` is the number of events observed in bin :math:`i`, and
  55 +
  56 +.. math::
  57 + e_i(M) = P(p'_i, E'_i ,t'_i | M) \times \Omega_i \times \Delta E_i \times
  58 + \Delta T_i
  59 +
  60 +is the predicted number of events from :ref:`model <um_models>` :math:`M` in
  61 +bin :math:`i`. The probability density is evaluated for the reference
  62 +instrument direction :math:`p'_i`, measured energy :math:`E'_i` and trigger
  63 +time :math:`t'_i` of bin :math:`i`, taken to be the values at the bin centre,
  64 +and multiplied by the solid angle :math:`\Omega_i`, the energy width
  65 +:math:`\Delta E_i` and the exposure time (or ontime) :math:`\Delta T_i` of
  66 +bin :math:`i` (note that a live time correction is included in the probability
  67 +density :math:`P(p'_i, E'_i ,t'_i | M)` so that the multiplication is done by
  68 +the true exposure time).
  69 +
  70 +
  71 +Binned data following Gaussian statistic
  72 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  73 +
  74 +Alternatively, if the data follow a Gaussian distribution the formula
  75 +
  76 +.. math::
  77 + -\ln L(M) = \frac{1}{2} \sum_i \left( \frac{n_i - e_i(M)}{\sigma_i} \right)^2
  78 +
  79 +is used, where :math:`\sigma_i` is the statistical uncertainty in the measured
  80 +number of events for bin :math:`i`.
  81 +
  82 +
  83 +On/Off analysis
  84 +~~~~~~~~~~~~~~~
  85 +
  86 +For a so-called On/Off analysis, where spectra from a source (or On) region
  87 +and source-free (or Off) region are analysed jointly, there exist two options:
  88 +``cstat`` and ``wstat``.
  89 +
  90 +cstat
  91 +^^^^^
  92 +
  93 +``cstat`` makes use of a background model :math:`M_b` and employs the Poisson
  94 +formula
  95 +
  96 +.. math::
  97 + -\ln L(M) = \sum_i s_i(M_s) + \alpha_i(M_b) \, b_i(M_b) -
  98 + n^\mathrm{on}_i \ln [s_i(M_s)+ \alpha_i(M_b) \, b_i(M_b)] + b_i(M_b) -
  99 + n^\mathrm{off}_i \ln b_i(M_b)
  100 +
  101 +where the :ref:`model <um_models>` :math:`M` is split into signal (i.e. gamma
  102 +rays) and background, i.e. :math:`M = M_s + M_b`,
  103 +:math:`n^\mathrm{on}_i` is the number of events in bin :math:`i` of the On
  104 +region,
  105 +:math:`n^\mathrm{off}_i` is the number of events in bin :math:`i` of the Off
  106 +region,
  107 +:math:`s_i(M_s)` is the number of expected signal counts in bin :math:`i` of
  108 +the On region,
  109 +:math:`b_i(M_b)` is the number of expected background counts in bin :math:`i`
  110 +of the Off region,
  111 +and
  112 +
  113 +.. math::
  114 + \alpha_i(M_b) = \frac{\int_\mathrm{on} M_b d\Omega}{\int_\mathrm{off} M_b d\Omega}
  115 +
  116 +is the ratio between the spatial integral over the background model in the On
  117 +region and the Off region for bin :math:`i`.
  118 +
  119 +wstat
  120 +^^^^^
  121 +
  122 +``wstat`` does not make use of an explicit background model but assumes that
  123 +the background rate per solid angle is the same in the On and the Off region.
  124 +The Poisson formula is then
  125 +
  126 +.. math::
  127 + -\ln L(M_s) = \sum_i s_i(M_s) + \alpha_i b_i(M_s) -
  128 + n^\mathrm{on}_i \ln [s_i(M_s)+ \alpha_i \, b_i(M_s)] + b_i(M_s) -
  129 + n^\mathrm{off}_i \ln b_i(M_s) -\\
  130 + n^\mathrm{on}_i (1-\ln n^\mathrm{on}_i) -
  131 + n^\mathrm{off}_i (1-\ln n^\mathrm{off}_i)
  132 +
  133 +Some special cases need to be handled separately in ``wstat``.
  134 +
  135 +If :math:`n^\mathrm{on}_i = 0` but :math:`n^\mathrm{off}_i > 0` the
  136 +contribution to the log-likelihood from the energy bin :math:`i` is
  137 +
  138 +.. math::
  139 + -\ln L_i(M_s) = s_i(M_s) + n^\mathrm{off}_i \ln(\alpha_i+1).
  140 +
  141 +If :math:`n^\mathrm{off}_i = 0` and
  142 +:math:`n^\mathrm{on}_i > s_i(M_s) \frac{\alpha_i + 1}{\alpha_i}`
  143 +the contribution to the log-likelihood from the energy bin :math:`i` is
  144 +
  145 +.. math::
  146 + -\ln L_i(M_s) = -\frac{s_i(M_s)}{\alpha_i} - n^\mathrm{on}_i
  147 + \ln\left(\frac{\alpha_i}{\alpha_i+1}\right)
  148 +
  149 +However, for smaller :math:`n^\mathrm{on}_i` the value of :math:`b_i(M_s)` is
  150 +null or negative. Since a negative number of background counts is unphysical,
  151 +the number of background counts is forced to be zero. This yields the following
  152 +expression for the log-likelihood in the energy bin :math:`i`:
  153 +
  154 +.. math::
  155 + -\ln L_i(M_s) = s_i(M_s) + n^\mathrm{on}_i \left( \ln n^\mathrm{on}_i - \ln s_i(M_s) - 1 \right)
  156 +
  157 +or, if also :math:`n^\mathrm{on}_i = 0`,
  158 +
  159 +.. math::
  160 + -\ln L_i(M_s) = s_i(M_s)
  161 +
  162 +Forcing the number of expected background counts to zero biases the likelihood
  163 +estimator. Therefore, ``wstat`` is known to be inaccurate if there are energy
  164 +bins with zero Off counts.
  165 +
  166 +
... ...