Skip to content

Commit 3db2728

Browse files
committed
simplied code, since only one evaluation order is relevant
1 parent a45fffb commit 3db2728

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/probabilit/iman_conover.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,11 @@ def __call__(self, X):
144144
# (3) Use LAPACK routine TRMM (scipy.linalg.blas.dtrmm)
145145
# I choose to implement (1) and (2), but avoid the LACACK calls for now.
146146

147-
if N < K: # Fewer rows (obs) than columns (vars) => left-to-right
148-
# Equivalent to: X_n = X_n @ np.linalg.inv(P).T
149-
X_n = sp.linalg.solve_triangular(
150-
P, X_n.T, lower=True
151-
).T # Removes existing correlations
152-
153-
X_n = X_n @ self.P.T # Adds new desired correlations
154-
155-
else: # More rows (obs) than columns (vars) => right-to-left
156-
transform = sp.linalg.solve_triangular(
157-
P.T, self.P.T, lower=False
158-
) # Remove existing + add desired, as one transformation
159-
X_n = X_n @ transform
160-
161-
return mean + X_n * std
147+
# When it comes to evaluation order (point (1) above), it's better to
148+
# evaluate left-to-right if N < K, and right-to-left if N > K.
149+
# Since N > K (must have rows > columns), we evaluate right-to-left
150+
transform = sp.linalg.solve_triangular(P.T, self.P.T, lower=False)
151+
return mean + X_n @ (transform * std)
162152

163153

164154
class ImanConover(Correlator):

0 commit comments

Comments
 (0)