From e00e529505087a5ccc63d70e5f2451a6a9b1c60d Mon Sep 17 00:00:00 2001 From: Lenz Fiedler Date: Mon, 27 Nov 2023 17:00:17 +0100 Subject: [PATCH] Adding +1.0 to the DOS to eliminate numerical errors --- mala/network/tester.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mala/network/tester.py b/mala/network/tester.py index 8eaa5c912..041602045 100644 --- a/mala/network/tester.py +++ b/mala/network/tester.py @@ -288,13 +288,15 @@ def __calculate_observable_error(self, snapshot_number, observable, read_additional_calculation_data( self.data.get_snapshot_calculation_output(snapshot_number)) + # We shift both the actual and predicted DOS by 1.0 to overcome + # numerical issues with the DOS having values equal to zero. target_calculator.read_from_array(actual_target) - actual = target_calculator.density_of_states + actual = target_calculator.density_of_states + 1.0 target_calculator.read_from_array(predicted_target) - predicted = target_calculator.density_of_states + predicted = target_calculator.density_of_states + 1.0 - return np.ma.masked_invalid(np.abs((actual - predicted) / (actual+predicted))).mean() * 100 + return np.ma.masked_invalid(np.abs((actual - predicted) / (actual))).mean() * 100 def __prepare_to_test(self, snapshot_number): """Prepare the tester class to for test run."""