mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-07-01 09:19:27 +02:00
I changed the name from range to prange (hope i did not miss something)
There is now an Eigenvalue method using the cholesky method you put in the example. I do not really use that, but it seems like a logical inclusion. I gave the standard fit an option to seht the number of fit parameters by hand, because it does not work automatically if the function is not consistent between calls.
This commit is contained in:
parent
014c0d12ce
commit
7c03cff42f
2 changed files with 80 additions and 38 deletions
|
@ -14,7 +14,7 @@ from autograd import elementwise_grad as egrad
|
|||
from .pyerrors import Obs, derived_observable, covariance, pseudo_Obs
|
||||
|
||||
|
||||
def standard_fit(x, y, func, silent=False, **kwargs):
|
||||
def standard_fit(x, y, func,n_parms="auto", silent=False, **kwargs):
|
||||
"""Performs a non-linear fit to y = func(x) and returns a list of Obs corresponding to the fit parameters.
|
||||
|
||||
x has to be a list of floats.
|
||||
|
@ -68,15 +68,19 @@ def standard_fit(x, y, func, silent=False, **kwargs):
|
|||
if not callable(func):
|
||||
raise TypeError('func has to be a function.')
|
||||
|
||||
for i in range(25):
|
||||
try:
|
||||
func(np.arange(i), x.T[0])
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
break
|
||||
if n_parms=="auto":
|
||||
for i in range(25):
|
||||
try:
|
||||
func(np.arange(i), x.T[0])
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
break
|
||||
|
||||
|
||||
n_parms = i
|
||||
n_parms = i
|
||||
|
||||
|
||||
if not silent:
|
||||
print('Fit with', n_parms, 'parameters')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue