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