likelihood_ratio

nbi_stat.likelihood_ratio(lh_h1, lh_h0, loglike=True)[source]

Calculate the likelihood ratio of hypothesis H1 to H0

Parameters:
  • lh_h1 (float) – (Logarithmic) likelihood of hypothesis H1

  • lh_h0 (float) – (Logarithmic) likelihood of hypothesis H0

  • loglike (bool (optional, default True)) – If true, then lh_h1 and lh_h0 are assummed to be the logarithmic likelihood of the hypothesis

Returns:

lambda

The likelihood ratio

lambda = 2 log (lh_h1 / lh_h0) = 2 (log(lh_h1) - log(lh_h0))

which is chi^2 distributed. Use scipy.stats.chi2.sf with 2 degrees of freedom to evaluate the p-value. Large p-value says we cannot reject the null-hypothesis H0 due to the hypothesis H1

Return type:

float