PEtab-dev / libpetab-python

Python package for working with PEtab files
https://libpetab-python.readthedocs.io
MIT License
14 stars 5 forks source link

Calculation of LLH in `calculate_llh` / `calculate_single_llh` #198

Closed fbergmann closed 1 year ago

fbergmann commented 1 year ago

Since our tool does not internally deal with LLHs, we use the provided functions in libpetab. The PEtab problem is the one from the petab_select test model 9.

If one of the simulation results produces 0, then with the log transformation defined in the table the reported LLH for those becomes infinite. The question is, if this is expected to happen, or how to deal with it.

One example input to compute_single_llh is:


calculate_single_llh(
        measurement: float,     # 0.0025276712
        simulation: float,           # 0.0
        scale: str,                       # 'log'
        noise_distribution: str,  # 'normal'
        noise_value: float.         # 1.0
) -> float                                 # -inf

for which

        nllh = 0.5*log(2*pi*sigma**2*m**2) + 0.5*((log(s)-log(m))/sigma)**2

is inf.

dilpath commented 1 year ago

Since the issue occurs in the simulation, perhaps there's an error with the model such that zero values are produced.

If you have a parameter vector that produces these zero values, I could try to debug it.

The data in the model are all "steady-state", at t=inf. Initially, some values might be zero, but by steady-state, all species should have some nonzero value.

fbergmann commented 1 year ago

I raised this issue more as a general question, of whether compute_llh should result with an inf value when a log scale is used. Or whether those values should be somehow filtered out.

As it seems the consensus is that this is the expected behaviour, so I'm fine with closing this issue. Thank you.