def get_chi2(self, fit_blending=None):
"""
Calculates chi^2 of current model by fitting for source and
blending fluxes.
Parameters :
fit_blending: *boolean*, optional
If True, then the blend flux is a free parameter. If
False, the blend flux is fixed at zero. Default is
the same as :py:func:`MulensModel.fit.Fit.fit_fluxes()`.
Returns :
chi2: *float*
Chi^2 value
"""
chi2_per_point = self.get_chi2_per_point(
fit_blending=fit_blending)
# Calculate chi^2 given the fit
chi2 = []
for i, dataset in enumerate(self.datasets):
# Calculate chi2 for the dataset excluding bad data
select = np.logical_not(dataset.bad)
chi2.append(fsum(chi2_per_point[i][select]))
self.chi2 = fsum(chi2)
if self.best_chi2 is None or self.best_chi2 > self.chi2:
self.best_chi2 = self.chi2
self.best_chi2_parameters = dict(self.model.parameters.parameters)
return self.chi2
评论列表
文章目录