Change request #2237

Add stat parameter to all likelihood tools to specify the statistics

Added by Knödlseder Jürgen about 7 years ago. Updated about 7 years ago.

Status:ClosedStart date:10/21/2017
Priority:NormalDue date:
Assigned To:Knödlseder Jürgen% Done:

100%

Category:-
Target version:1.5.0
Duration:

Description

We should add a stat parameter to all likelihood tool to specify the statistics.

Even better, we should rename stat to statistic since it’s not too long and is clearer.


Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen about 7 years ago

  • Assigned To set to Knödlseder Jürgen
  • % Done changed from 0 to 50

I renamed the stat parameter of ctlike into statistic. The parameter is now set to DEFAULT which means that the default optimization statistic that is in the observation container is used.

I added statistic parameters following the same logic to ctbutterfly, cterror, cttsmap, and ctulimit. I have not yet checked if the statistic parameter is actually correctly taken into account, but I added a unit test for the ctlikelihood::set_obs_statistic() method that handles the statistic setting.

I also changed csspec so that it derives now from cslikelihood. In that way it can benefit from the ctlikelihood::set_obs_statistic() method. The observation container is no longer stored in self._obs but in the ctlikelihood::m_obs data member.

I checked that running csspec with default or CSTAT and running the script with WSTAT actually leads to different results, and that the corresponding likelihood functions got called. For reference, here the difference in the fitted SED for some test data:

WSTAT
2017-10-21T21:15:22:  Bin 1 .....................: 1.373113e-10 +/- 3.812628e-12 [< 1.754375e-10] erg/cm2/s (TS = 1087.498)
2017-10-21T21:15:22:  Bin 2 .....................: 1.045101e-10 +/- 3.041434e-12 [< 1.349244e-10] erg/cm2/s (TS = 1057.596)
2017-10-21T21:15:22:  Bin 3 .....................: 1.077106e-10 +/- 3.147502e-12 [< 1.391855e-10] erg/cm2/s (TS = 1113.398)
2017-10-21T21:15:22:  Bin 4 .....................: 8.732562e-11 +/- 2.718267e-12 [< 1.145082e-10] erg/cm2/s (TS = 1038.574)
2017-10-21T21:15:22:  Bin 5 .....................: 6.957374e-11 +/- 2.422369e-12 [< 9.379738e-11] erg/cm2/s (TS = 870.357)
2017-10-21T21:15:22:  Bin 6 .....................: 5.656150e-11 +/- 2.233978e-12 [< 7.890123e-11] erg/cm2/s (TS = 692.162)
2017-10-21T21:15:22:  Bin 7 .....................: 4.858075e-11 +/- 2.090007e-12 [< 6.948078e-11] erg/cm2/s (TS = 597.593)
2017-10-21T21:15:22:  Bin 8 .....................: 4.659159e-11 +/- 2.116632e-12 [< 6.775789e-11] erg/cm2/s (TS = 534.525)
2017-10-21T21:15:22:  Bin 9 .....................: 3.321563e-11 +/- 1.877694e-12 [< 5.199255e-11] erg/cm2/s (TS = 350.602)
2017-10-21T21:15:22:  Bin 10 ....................: 3.395876e-11 +/- 2.121357e-12 [< 5.517231e-11] erg/cm2/s (TS = 346.723)
2017-10-21T21:15:22:  Bin 11 ....................: 1.773108e-11 +/- 1.619726e-12 [< 3.392832e-11] erg/cm2/s (TS = 128.381)
2017-10-21T21:15:22:  Bin 12 ....................: 1.850342e-11 +/- 1.864752e-12 [< 3.715092e-11] erg/cm2/s (TS = 106.198)
2017-10-21T21:15:22:  Bin 13 ....................: 2.100709e-11 +/- 3.408607e-12 [< 5.509315e-11] erg/cm2/s (TS = 117.038)
2017-10-21T21:15:22:  Bin 14 ....................: 1.815640e-11 +/- 3.209699e-12 [< 5.025339e-11] erg/cm2/s (TS = 69.478)
2017-10-21T21:15:22:  Bin 15 ....................: 1.258479e-11 +/- 3.364222e-12 [< 4.622700e-11] erg/cm2/s
2017-10-21T21:15:22:  Bin 16 ....................: 1.066218e-11 +/- 4.353846e-12 [< 5.420063e-11] erg/cm2/s
2017-10-21T21:15:22:  Bin 17 ....................: 9.033290e-12 +/- 3.011809e-12 [< 3.915137e-11] erg/cm2/s
2017-10-21T21:15:22:  Bin 18 ....................: 7.653251e-12 +/- 3.827531e-12 [< 4.592856e-11] erg/cm2/s
2017-10-21T21:15:22:  Bin 19 ....................: 6.484044e-12 +/- 0.000000e+00 [< 7.132448e-11] erg/cm2/s
2017-10-21T21:15:22:  Bin 20 ....................: 5.493460e-12 +/- 0.000000e+00 [< 6.042805e-11] erg/cm2/s

CSTAT
2017-10-21T20:45:41:  Bin 1 .....................: 1.373656e-10 +/- 6.030624e-12 [< 1.976718e-10] erg/cm2/s (TS = 1088.775)
2017-10-21T20:45:41:  Bin 2 .....................: 1.042587e-10 +/- 4.794084e-12 [< 1.521995e-10] erg/cm2/s (TS = 1062.849)
2017-10-21T20:45:41:  Bin 3 .....................: 1.078725e-10 +/- 4.977025e-12 [< 1.576427e-10] erg/cm2/s (TS = 1112.421)
2017-10-21T20:45:41:  Bin 4 .....................: 8.762697e-11 +/- 4.295399e-12 [< 1.305809e-10] erg/cm2/s (TS = 1035.871)
2017-10-21T20:45:41:  Bin 5 .....................: 6.986765e-11 +/- 3.827805e-12 [< 1.081457e-10] erg/cm2/s (TS = 868.705)
2017-10-21T20:45:41:  Bin 6 .....................: 5.670564e-11 +/- 3.522832e-12 [< 9.193392e-11] erg/cm2/s (TS = 690.559)
2017-10-21T20:45:41:  Bin 7 .....................: 4.872281e-11 +/- 3.295550e-12 [< 8.167827e-11] erg/cm2/s (TS = 595.845)
2017-10-21T20:45:41:  Bin 8 .....................: 4.678697e-11 +/- 3.335691e-12 [< 8.014386e-11] erg/cm2/s (TS = 536.790)
2017-10-21T20:45:41:  Bin 9 .....................: 3.296117e-11 +/- 2.933138e-12 [< 6.229252e-11] erg/cm2/s (TS = 350.816)
2017-10-21T20:45:41:  Bin 10 ....................: 3.414304e-11 +/- 3.132408e-12 [< 6.546711e-11] erg/cm2/s (TS = 345.622)
2017-10-21T20:45:41:  Bin 11 ....................: 1.757857e-11 +/- 2.494777e-12 [< 4.252633e-11] erg/cm2/s (TS = 129.887)
2017-10-21T20:45:41:  Bin 12 ....................: 1.832112e-11 +/- 2.858257e-12 [< 4.690368e-11] erg/cm2/s (TS = 106.383)
2017-10-21T20:45:41:  Bin 13 ....................: 2.100710e-11 +/- 3.300950e-11 [< 8.577811e-11] erg/cm2/s (TS = 123.839)
2017-10-21T20:45:41:  Bin 14 ....................: 1.821459e-11 +/- 6.688968e-12 [< 7.087034e-11] erg/cm2/s (TS = 71.630)
2017-10-21T20:45:41:  Bin 15 ....................: 1.425697e-11 +/- 1.835423e-11 [< 6.219684e-11] erg/cm2/s (TS = 49.067)
2017-10-21T20:45:41:  Bin 16 ....................: 1.085186e-11 +/- 2.643605e-11 [< 1.362755e-10] erg/cm2/s (TS = 144.719)
2017-10-21T20:45:41:  Bin 17 ....................: 1.745800e-11 +/- 1.241720e-10 [< 3.450824e-10] erg/cm2/s (TS = 280.243)
2017-10-21T20:45:41:  Bin 18 ....................: 1.122167e-11 +/- 4.623641e-11 [< 2.467699e-10] erg/cm2/s (TS = 139.358)
2017-10-21T20:45:41:  Bin 19 ....................: 6.484044e-12 +/- 0.000000e+00 [< 7.279449e-12] erg/cm2/s
2017-10-21T20:45:41:  Bin 20 ....................: 5.493460e-12 +/- 0.000000e+00 [< 1.092135e-11] erg/cm2/s

I merged the code into devel.

I still need to modify all other cscripts that do maximum likelihood fitting (e.g. cslightcrv, csphasecrv).

#2 Updated by Knödlseder Jürgen about 7 years ago

The following tools and scripts now have a statistic parameter:
  • ctbutterfly
  • cterror
  • ctlike
  • cttsmap
  • ctulimit
  • cslightcrv
  • csphasecrv
  • cspull
  • cssens
  • csspec
  • cstsdist
  • cstsmapsplit

Except of cstsmapsplit, all the above mentioned cscripts now derive from cslikelihood, using the internal storage for the observation container and the cslikelihood.set_obs_statistic method to set the statistic for the observations.

Everything has been merged into devel.

#3 Updated by Knödlseder Jürgen about 7 years ago

  • Status changed from New to Closed
  • % Done changed from 50 to 100

#4 Updated by Knödlseder Jürgen about 7 years ago

Moved the set_obs_statistic() method from cslikelihood to csobservation since scripts using the method do in general not need an optimizer, and the method only operations on observations.

Also available in: Atom PDF