Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow calculating llhs #349

Merged
merged 12 commits into from
Feb 27, 2020
Prev Previous commit
Next Next commit
init llh
  • Loading branch information
yannikschaelte committed Feb 27, 2020
commit 020a343b855026807f8f59737b0358c7a430b987
14 changes: 14 additions & 0 deletions petab/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,17 @@ def calculate_chi2_for_table_from_residuals(
residual_df: pd.DataFrame) -> float:
"""Compute chi2 value for a single residual table."""
return (np.array(residual_df[RESIDUAL])**2).sum()


def calculate_llh(
measurement_dfs: Union[List[pd.DataFrame], pd.DataFrame],
simulation_dfs: Union[List[pd.DataFrame], pd.DataFrame],
observable_dfs: Union[List[pd.DataFrame], pd.DataFrame],
parameter_dfs: Union[List[pd.DataFrame], pd.DataFrame],
normalize: bool = True,
scale: bool = True
) -> float:
residual_dfs = calculate_residuals(
measurement_dfs, simulation_dfs, observable_dfs, parameter_dfs,
normalize, scale)
llhs = [calculate_llh_for_table_from_residuals(residual_df,