Skip to content

alternate fitting statistics with Model interface #993

@ggggggggg

Description

@ggggggggg

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:

  1. Not available through the very desirable Model interface.
  2. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions