Git Product home page Git Product logo

Comments (5)

s-kuberski avatar s-kuberski commented on July 28, 2024

Hm. You are right, this looks suspicious. I have made the following observations:

  • If you perform a two-parameter fit and use the result for one of the resulting parameters to constrain a new one-parameter fits, the error on the free parameter does not change. I thought, that this was supposed to happen, since the fit parameters are not independent of each other.
  • Whether you add/remove an offset using an Obs (see my code) exactly or constrain the fit should not make any difference for the mean value of the free parameter (this is the case). However, somehow one could expect the error to be independent of the procedure, as well (this is certainly not the case).
  • The dependence of the error of the free fit parameter on the error of the constrained one is not entirely clear to me. My current implementation seems to lead to a result, where the error of the free parameter is insensitive to the constraint. This makes sense, when I think about how the error propagation is implemented. You are right: If the constraint has a very small error, the constrained-two-parameter fit should lead to a similar result as the one-parameter fit to the shifted data set.

I have to find the conceptual error in the current implementation...

dim = 10
x = np.arange(dim)
y = -0.06 * x +  np.random.normal(0.0, 0.25, dim)
yerr = [0.3] * dim

oy = []
for i, item in enumerate(x):
    oy.append(pe.pseudo_Obs(y[i], yerr[i], 'test'))

shift = pe.pseudo_Obs(1, .0000000001, 'shift')

oy = [o + shift for o in oy]
[o.gamma_method() for o in oy]

def func(a, x):
    y = a[0] * x + a[1]
    return y

# Fit with constrained parameter
out = pe.least_squares(x, oy, func, const_par=[shift])

def alt_func(a, x):
    y = a[0] * x
    return y

alt_y = np.array(oy) - shift
[o.gamma_method() for o in alt_y]

# Fit with the constant subtracted from the data
alt_out = pe.least_squares(x, alt_y, alt_func)

# Fit to the data with two free parameters
twop_out = pe.least_squares(x, oy, func)

print(out, '\n', alt_out, '\n', twop_out)

from pyerrors.

s-kuberski avatar s-kuberski commented on July 28, 2024

Maybe the implementation is too simple and one should use Lagrange multipliers (together with MINUIT). There seems to be some discussion (and a fit package https://www.desy.de/~sschmitt/blobel/wwwcondl.html ) in the experimental community.

from pyerrors.

fjosw avatar fjosw commented on July 28, 2024

As the issue seems to be rather complicated I would propose to remove the feature from the develop version in order to not delay the 2.0 release any further and put it on our agenda for the next minor release 2.1 for which I wanted to rework parts of the fitting routines anyway.

from pyerrors.

s-kuberski avatar s-kuberski commented on July 28, 2024

This seems to be the best way to handle this right now.

from pyerrors.

fjosw avatar fjosw commented on July 28, 2024

I temporarily removed the feature from the develop branch in commit 2a925ba.

from pyerrors.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.