Skip to content

Commit 096286d

Browse files
committed
refactor ap jacobians, following ryans approach
1 parent 5aa0837 commit 096286d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

fooof/core/jacobians.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ def jacobian_expo(xs, *params):
7070
"""
7171

7272
a, b, c = params
73-
jacobian = np.hstack([
74-
np.ones([len(xs), 1]),
75-
- (1 / (b + xs**c)).reshape(-1, 1),
76-
-((xs**c * np.log10(xs)) / (b + xs**c)).reshape(-1, 1),
77-
])
73+
74+
xs_c = xs**c
75+
b_xs_c = xs_c + b
76+
77+
jacobian = np.ones((len(xs), len(params)))
78+
jacobian[:, 1] = -1 / b_xs_c
79+
jacobian[:, 2] = -(xs_c * np.log10(xs)) / b_xs_c
7880

7981
return jacobian
8082

@@ -95,9 +97,7 @@ def jacobian_expo_nk(xs, *params):
9597
Jacobian matrix, with shape [len(xs), n_params].
9698
"""
9799

98-
jacobian = np.hstack([
99-
np.ones([len(xs), 1]),
100-
(-np.log10(xs) / np.log10(10)).reshape(-1, 1),
101-
])
100+
jacobian = np.ones((len(xs), len(params)))
101+
jacobian[:, 1] = -np.log10(xs)
102102

103103
return jacobian

0 commit comments

Comments
 (0)