Comments (5)
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.
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.
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.
This seems to be the best way to handle this right now.
from pyerrors.
I temporarily removed the feature from the develop branch in commit 2a925ba.
from pyerrors.
Related Issues (20)
- numerical differentiation in derived_obs not working HOT 5
- Automatic windowing method fails for gapped and irregular chains HOT 4
- Issues with _filter_zeroes and Corr HOT 4
- Exception when applying .symmetric() to Corr containing None HOT 1
- Gamma_method() is broken for Obs that are NaN
- Multi-dimensional fits
- Bug coming from difference in search methods in sfcf inputs HOT 2
- `Corr.show()` draws prange in same color as error bars. HOT 1
- No dobs-related functions from the input submodule can be used HOT 1
- GEVP eigenvectors with errors HOT 7
- Warning in pandas tests
- Numpy 1.25 breaks a few linalg functions HOT 3
- Failing python 3.12 pytest workflow
- Duplicate data cause `gamma_method()` to fail with an unhelpful message HOT 3
- plot_history unexpected behaviour for gapped idl HOT 2
- read_hd5 in pyerrors 2.9.0 not fully backwards compatible to <=2.8.2 HOT 1
- Read specific interval with read_ms5_xsf() HOT 2
- Files keyword for multiple reps in read_sfcf HOT 2
- pyerrors does not work with the upcoming numpy 2 release HOT 7
- Corr.__getitem__ unexpected behaviour HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyerrors.