1
- """"Functions for computing Jacobian matrices to be used during fitting."""
1
+ """"Functions for computing Jacobian matrices to be used during fitting.
2
+
3
+ Notes
4
+ -----
5
+ These functions line up with those in `funcs`.
6
+ The parameters in these functions are labelled {a, b, c, ...}, but follow the order in `funcs`.
7
+ These functions are designed to be passed into `curve_fit` to provide a computed Jacobian.
8
+ """
2
9
3
10
import numpy as np
4
11
8
15
## Periodic fit functions
9
16
10
17
def jacobian_gauss (xs , * params ):
11
- """Create the Jacobian matrix for the Guassian function."""
18
+ """Create the Jacobian matrix for the Guassian function.
19
+
20
+ Parameters
21
+ ----------
22
+ xs : 1d array
23
+ Input x-axis values.
24
+ *params : float
25
+ Parameters for the function.
26
+
27
+ Returns
28
+ -------
29
+ jacobian : 2d array
30
+ Jacobian matrix, with shape [len(xs), n_params].
31
+ """
12
32
13
33
jacobians = []
14
34
for a , b , c in zip (* [iter (params )] * 3 ):
@@ -28,7 +48,20 @@ def jacobian_gauss(xs, *params):
28
48
## Aperiodic fit functions
29
49
30
50
def jacobian_expo (xs , * params ):
31
- """Create the Jacobian matrix for the exponential function."""
51
+ """Create the Jacobian matrix for the exponential function.
52
+
53
+ Parameters
54
+ ----------
55
+ xs : 1d array
56
+ Input x-axis values.
57
+ *params : float
58
+ Parameters for the function.
59
+
60
+ Returns
61
+ -------
62
+ jacobian : 2d array
63
+ Jacobian matrix, with shape [len(xs), n_params].
64
+ """
32
65
33
66
a , b , c = params
34
67
jacobian = np .hstack ([
@@ -41,7 +74,20 @@ def jacobian_expo(xs, *params):
41
74
42
75
43
76
def jacobian_expo_nk (xs , * params ):
44
- """Create the Jacobian matrix for the exponential no-knee function."""
77
+ """Create the Jacobian matrix for the exponential no-knee function.
78
+
79
+ Parameters
80
+ ----------
81
+ xs : 1d array
82
+ Input x-axis values.
83
+ *params : float
84
+ Parameters for the function.
85
+
86
+ Returns
87
+ -------
88
+ jacobian : 2d array
89
+ Jacobian matrix, with shape [len(xs), n_params].
90
+ """
45
91
46
92
jacobian = np .hstack ([
47
93
np .ones ([len (xs ), 1 ]),
0 commit comments