minaskar / zeus

⚡️ zeus: Lightning Fast MCMC ⚡️
https://zeus-mcmc.readthedocs.io/
GNU General Public License v3.0
225 stars 34 forks source link

Print parameter values if likelihood fails #19

Closed seshnadathur closed 3 years ago

seshnadathur commented 3 years ago

I am working with a problem where some points in parameter space give invalid inputs for which my likelihood fails. When this happens, I would like zeus to print the parameter values at the point that caused the failure (as is done by emcee) to make it easier to debug/understand the physical reason for the likelihood failure.

Can you implement this please?

minaskar commented 3 years ago

What exact value does your log-likelihood return when evaluated in one such point? Is it np.nan?

seshnadathur commented 3 years ago

I'm not sure: as I couldn't find the parameter values at which the failure occurred it is not so simple to reproduce it. If I come across it again I will check and let you know. Does it affect the fix you would need to implement?

seshnadathur commented 3 years ago

I should add that the running a chain with the exact same likelihood using emcee I hit a (probably similar) failure point, and emcee spat out the parameter values at that point. This was useful for me to code a workaround in the likelihood (which also now means that failure doesn't recur, so it's less easy to answer your question).

minaskar commented 3 years ago

I think I know what you mean. It's not when the likelihood returns an invalid value (e.g. np.nan) but when the likelihood raises an exception.

Could you confirm that the error message emcee provided looked like this?

emcee: Exception while calling your likelihood function:
  params: [-2.85976993  5.04287664]
  args: []
  kwargs: {}
  exception:
seshnadathur commented 3 years ago

Yes, that's right. Sorry about the confusing wording earlier!

minaskar commented 3 years ago

No worries. I'l implement it during the next few days.

minaskar commented 3 years ago

Sorry for the delay. Let me know if the feature works.