Skip to content

Commit

Permalink
Fix #37 by ignoring self edges in MLE estimate
Browse files Browse the repository at this point in the history
  • Loading branch information
jchodera committed Jan 8, 2022
1 parent 1d2c6fe commit 78c8358
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions openff/arsenic/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def mle(
Xu, Huafengraph. "Optimal measurement network of pairwise differences."
Journal of Chemical Information and Modeling 59.11 (2019): 4720-4728.
NOTE: Self-edges (edges that connect a node to itself) will be ignored.
Parameters
----------
graph :nx.Graph
Expand Down Expand Up @@ -191,6 +193,9 @@ def mle(
for (a, b) in graph.edges:
i = node_name_to_index[a]
j = node_name_to_index[b]
if i == j:
# The MLE solver will fail if we include self-edges, so we need to omit these
continue
F_matrix[i, j] = -df_ij[i, j] ** (-2)
F_matrix[j, i] = -df_ij[i, j] ** (-2)
for n in graph.nodes:
Expand All @@ -209,6 +214,9 @@ def mle(
for (a, b) in graph.edges:
i = node_name_to_index[a]
j = node_name_to_index[b]
if i == j:
# The MLE solver will fail if we include self-edges, so we need to omit these
continue
z[i] += f_ij[i, j] * df_ij[i, j] ** (-2)
z[j] += f_ij[j, i] * df_ij[j, i] ** (-2)

Expand Down

0 comments on commit 78c8358

Please sign in to comment.