Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jackaraz committed Oct 21, 2024
1 parent 6b9062f commit e854cdb
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions src/spey/combiner/uncorrelated_statistics_combiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
of different statistical models for hypothesis testing
"""

import logging
import warnings
from typing import Dict, Iterator, List, Optional, Text, Tuple, Union

Expand All @@ -17,6 +18,8 @@

__all__ = ["UnCorrStatisticsCombiner"]

log = logging.getLogger("Spey")


class UnCorrStatisticsCombiner(HypothesisTestingBase):
"""
Expand Down Expand Up @@ -494,27 +497,31 @@ def maximize_likelihood(
# muhat initial value estimation in gaussian limit
mu_init = initial_muhat_value or 0.0
if initial_muhat_value is None:
_mu, _sigma_mu = np.zeros(len(self)), np.ones(len(self))
for idx, stat_model in enumerate(self):
try:
_mu, _sigma_mu = np.zeros(len(self)), np.ones(len(self))
for idx, stat_model in enumerate(self):

current_kwargs = {}
current_kwargs.update(
statistical_model_options.get(str(stat_model.backend_type), {})
)
current_kwargs = {}
current_kwargs.update(
statistical_model_options.get(str(stat_model.backend_type), {})
)

_mu[idx] = stat_model.maximize_likelihood(
expected=expected, **current_kwargs, **optimiser_options
)[0]
_sigma_mu[idx] = stat_model.sigma_mu(
poi_test=_mu[idx],
expected=expected,
**current_kwargs,
**optimiser_options,
_mu[idx] = stat_model.maximize_likelihood(
expected=expected, **current_kwargs, **optimiser_options
)[0]
_sigma_mu[idx] = stat_model.sigma_mu(
poi_test=_mu[idx],
expected=expected,
**current_kwargs,
**optimiser_options,
)
norm = np.sum(np.power(_sigma_mu, -2))
mu_init = np.true_divide(1.0, norm) * np.sum(
np.true_divide(_mu, np.square(_sigma_mu))
)
norm = np.sum(np.power(_sigma_mu, -2))
mu_init = np.true_divide(1.0, norm) * np.sum(
np.true_divide(_mu, np.square(_sigma_mu))
)
except Exception as err:
log.debug(str(err))
mu_init = 0.0

config: ModelConfig = ModelConfig(
poi_index=0,
Expand Down

0 comments on commit e854cdb

Please sign in to comment.