@@ -54,10 +54,19 @@ def evaluate(self, fit, count_fixed=False, kshift=0):
54
54
"""Return quality of fit for given ModelCluster using AIC (Akaike's Information Criterion).
55
55
56
56
Parameters
57
- fit: A ModelCluster
58
- count_fixed: Whether fixed parameters are considered.
59
- kshift: (0) Treat the model has having this many additional
60
- parameters. Negative values also allowed."""
57
+ ----------
58
+ fit : ModelCluster instance
59
+ The ModelCluster instance to evaluate.
60
+ count_fixed : bool
61
+ Whether fixed parameters are considered. Default is False.
62
+ kshift : int
63
+ Treat the model has having this many additional
64
+ parameters. Negative values also allowed. Default is 0.
65
+
66
+ Returns
67
+ -------
68
+ quality : float
69
+ The quality of fit for given ModelCluster."""
61
70
# Number of parameters. By default, fixed parameters are ignored.
62
71
k = fit .model .npars (count_fixed = count_fixed ) + kshift
63
72
if k < 0 :
@@ -79,12 +88,34 @@ def evaluate(self, fit, count_fixed=False, kshift=0):
79
88
return self .stat
80
89
81
90
def minpoints (self , npars ):
82
- """Calculates the minimum number of points required to make an estimate of a model's quality."""
91
+ """Calculates the minimum number of points required to make an estimate of a model's quality.
92
+
93
+ Parameters
94
+ ----------
95
+ npars : int
96
+ The number of parameters in the model.
97
+
98
+ Returns
99
+ -------
100
+ int
101
+ The minimum number of points required to make an estimate of a model's quality.
102
+ """
83
103
84
104
return 1
85
105
86
- def parpenalty (self , k , n ):
87
- """Returns the cost for adding k parameters to the current model cluster."""
106
+ def parpenalty (self , k ):
107
+ """Returns the cost for adding k parameters to the current model cluster.
108
+
109
+ Parameters
110
+ ----------
111
+ k : int
112
+ The number of added parameters in the model.
113
+
114
+ Returns
115
+ -------
116
+ float
117
+ The penalty cost for adding k parameters to the current model cluster.
118
+ """
88
119
89
120
# Weight the penalty for additional parameters.
90
121
# If this isn't 1 there had better be a good reason.
@@ -94,11 +125,26 @@ def parpenalty(self, k, n):
94
125
95
126
def growth_justified (self , fit , k_prime ):
96
127
"""Returns whether adding k_prime parameters to the given model (ModelCluster) is justified
97
- given the current quality of the fit. The assumption is that adding k_prime parameters will
128
+ given the current quality of the fit.
129
+
130
+ The assumption is that adding k_prime parameters will
98
131
result in "effectively 0" chiSquared cost, and so adding it is justified if the cost of adding
99
132
these parameters is less than the current chiSquared cost.
100
133
The validity of this assumption (which depends on an unknown chiSquared value)
101
134
and the impact of the errors used should be examined more thoroughly in the future.
135
+
136
+ Parameters
137
+ ----------
138
+ fit : ModelCluster instance
139
+ The ModelCluster instance to evaluate.
140
+
141
+ k_prime : int
142
+ The prime number of added parameters in the model.
143
+
144
+ Returns
145
+ -------
146
+ bool
147
+ Whether adding k_prime parameters to the given model is justified.
102
148
"""
103
149
104
150
if self .chisq is None :
@@ -124,15 +170,36 @@ def growth_justified(self, fit, k_prime):
124
170
125
171
@staticmethod
126
172
def akaikeweights (aics ):
127
- """Return sequence of Akaike weights for sequence of AICs"""
173
+ """Return sequence of Akaike weights for sequence of AICs
174
+
175
+ Parameters
176
+ ----------
177
+ aics : array-like
178
+ The sequence of AIC instance.
179
+
180
+ Returns
181
+ -------
182
+ array-like
183
+ The sequence of Akaike weights
184
+ """
128
185
129
186
aic_stats = np .array ([aic .stat for aic in aics ])
130
187
aic_min = min (aic_stats )
131
188
return np .exp (- (aic_stats - aic_min ) / 2.0 )
132
189
133
190
@staticmethod
134
191
def akaikeprobs (aics ):
135
- """Return sequence of Akaike probabilities for sequence of AICs"""
192
+ """Return sequence of Akaike probabilities for sequence of AICs
193
+
194
+ Parameters
195
+ ----------
196
+ aics : array-like
197
+ The sequence of AIC instance.
198
+
199
+ Returns
200
+ -------
201
+ array-like
202
+ The sequence of Akaike probabilities"""
136
203
aic_weights = AIC .akaikeweights (aics )
137
204
return aic_weights / np .sum (aic_weights )
138
205
0 commit comments