Skip to content

Commit

Permalink
🩹 Transform standard error if parameter has non_negative constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnel authored and s-weigand committed May 26, 2023
1 parent 1470d4a commit 364071a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion glotaran/optimization/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from glotaran.optimization.optimization_group import OptimizationGroup
from glotaran.optimization.optimization_history import OptimizationHistory
from glotaran.parameter import ParameterHistory
from glotaran.parameter.parameter import _log_value
from glotaran.project import Result
from glotaran.project import Scheme
from glotaran.utils.regex import RegexPattern
Expand Down Expand Up @@ -299,7 +300,14 @@ def calculate_covariance_matrix_and_standard_errors(
covariance_matrix = (jacobian_rsv[mask].T / jacobian_sv_square[mask]) @ jacobian_rsv[mask]
standard_errors = root_mean_square_error * np.sqrt(np.diag(covariance_matrix))
for label, error in zip(self._free_parameter_labels, standard_errors):
self._parameters.get(label).standard_error = error
parameter = self._parameters.get(label)
if parameter.non_negative:
if error < np.abs(_log_value(parameter.value)):
parameter.standard_error = parameter.value * (np.exp(error) - 1.0)
else:
parameter.standard_error = np.abs(parameter.value)
else:
self._parameters.get(label).standard_error = error
return covariance_matrix

@staticmethod
Expand Down

0 comments on commit 364071a

Please sign in to comment.