Skip to content

Commit

Permalink
reshape forse è più chiaro
Browse files Browse the repository at this point in the history
  • Loading branch information
enrdrigo committed Oct 1, 2024
1 parent 5baf2d9 commit 3eb0884
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions sportran/md/maxlike.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,15 @@ def _optimize_parameters(self, guess_data, minimize_kwargs, write_log):

self._store_optimization_results(res, write_log)

def _optimize_alpha(self, res):
samples = generate_samples_mc_alpha(res.x, res.hess_inv)

dic_alpha = reweight_logev_alpha_vec(alpha=self.alpha, samples=samples)

parameters_mean, parameters_cov = reweight_alpha(alpha=dic_alpha['alpha_s'], samples=samples)

return dic_alpha, parameters_mean, parameters_cov

def _store_optimization_results(self, res, write_log):
"""
Store the results of the optimization.
Expand All @@ -438,14 +447,9 @@ def _store_optimization_results(self, res, write_log):
the posterior at alpha=0: see reweight_alpha and reweight_logev_alpha_vec.
"""

samples = generate_samples_mc_alpha(res.x, res.hess_inv)

dic_alpha = reweight_logev_alpha_vec(alpha=self.alpha, samples=samples)

self.parameters_mean, self.parameters_cov = reweight_alpha(alpha=dic_alpha['alpha_s'], samples=samples)
self.best_alpha, self.parameters_mean, self.parameters_cov = self._optimize_alpha(res=res)

self.parameters_std = np.sqrt(self.parameters_cov.diagonal())
self.best_alpha = dic_alpha
else:
if write_log:
log.write_log(
Expand Down

0 comments on commit 3eb0884

Please sign in to comment.