JohannesBuchner / BXA

Bayesian X-ray analysis (nested sampling for Xspec and Sherpa)
https://johannesbuchner.github.io/BXA/
GNU General Public License v3.0
57 stars 19 forks source link

How is the logl value computed wrt to the Sherpa Wstat ? #47

Closed facero closed 1 year ago

facero commented 1 year ago

Description

As a way to understand how the NS works and to visualize the evolution of likelihood as a function of iterations, I'm looking at the logL column in the weighted_post.txt.

I'm using unbinned X-ray spectral data and the set_stat("wstat") in Sherpa. The background is extracted from the same observation. The BXA file weighted_post.txt looks this : image

In this case, the BXA maximized the logL value (the last rows with higher value are better) whereas in the sherpa or Xspec implementation, we minize Cstat or Wstat. How is this logL value is calculated ? Can it be related to Wstat value computed by sherpa ?

One the thing I'm trying is comparing the Wstat values from sherpa's fit to the solutions found by BXA.

JohannesBuchner commented 1 year ago

Have a look at the log-likelihood definition:

with pyxspec: https://github.com/JohannesBuchner/BXA/blob/master/bxa/xspec/solver.py#L160

with sherpa: https://github.com/JohannesBuchner/BXA/blob/master/bxa/sherpa/solver.py#L123

facero commented 1 year ago

Ah ok so it keeps the original Sherpa choice and just mulitply by -0.5. Thanks