-
Notifications
You must be signed in to change notification settings - Fork 288
Description
I often fit data from single photon sensing spectrometers with few counts, meaning that I often have bins that have zero or 1 count in them along with bins that have 100s or thousands of counts. The sherpa fitting package for chandra offers the "cash statistic" for this case: https://cxc.cfa.harvard.edu/sherpa/ahelp/cash.html and offers a general method for modifying the fit statistic: https://cxc.cfa.harvard.edu/sherpa/statistics/
As far as I can tell, the closest thing in lmfit is the reduce_fcn argument to Minimizer. The docs for reduce_fcn say:
Function to convert a residual array to a scalar value for the scalar minimizers. Optional values are (where r is the residual array):
None : sum-of-squares of residual (default)
= (r*r).sum()
’negentropy’ : neg entropy, using normal distribution
= rho*log(rho).sum()`, where rho = exp(-r*r/2)/(sqrt(2*pi))
’neglogcauchy’ : neg log likelihood, using Cauchy distribution
= -log(1/(pi*(1+r*r))).sum()
callable : must take one argument (r) and return a float.
So reduce_fcn allows the same modifications to fit statistics, but appears limited in the following ways:
- Not available through the very desirable
Modelinterface. - Only works with scalar minimizers.
I think that allowing the use of reduce_fcn or similar through the Model interface and with non-scalar minimizers would be a valuable addition to LMfit. If you like the idea, what would be a good path to do so?