Skip to content

Commit

Permalink
Adding +1.0 to the DOS to eliminate numerical errors
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomDefaultUser committed Nov 27, 2023
1 parent 6d1ea1e commit e00e529
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mala/network/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit e00e529

Please sign in to comment.