I'm trying to perform a fit with extended Chebyshev pdf. To do so I use predefined zfit.pdf.Chebyshev()
. What do I miss here?
import tensorflow as tf
import zfit
from zfit import ztf
obs = zfit.Space('mass', limits=(-1000., 1000.))
slope = zfit.Parameter("slope", -0.1, -1., 1., floating = True)
Nbkg = zfit.Parameter("Nbkg", 10, 0., 1000)
bkg_pdf = Nbkg*zfit.pdf.Chebyshev(obs =obs, coeffs = [slope])
With all predefined polynomials (Chebyshev/Legendre/Hermite), I'm getting the following error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-a86d6be1cc9d> in <module>
2 slope = zfit.Parameter("slope", -0.1, -1., 1., floating = True)
3 Nbkg = zfit.Parameter("Nbkg", 10, 0., 1000)
----> 4 bkg_pdf = Nbkg*zfit.pdf.Chebyshev(obs =obs, coeffs = [slope])
5
6
~/soft/minconda3/envs/my-analysis-env/lib/python3.7/site-packages/zfit/core/parameter.py in __mul__(self, other)
289 from . import operations
290 with suppress(NotImplementedError):
--> 291 return operations.multiply(self, other)
292 return super().__mul__(other)
293
~/soft/minconda3/envs/my-analysis-env/lib/python3.7/site-packages/zfit/core/operations.py in multiply(object1, object2)
34 new_object = multiply_param_func(param=object1, func=object2)
35 elif isinstance(object2, ZfitPDF):
---> 36 new_object = multiply_param_pdf(param=object1, pdf=object2)
37 else:
38 assert False, "This code should never be reached due to logical reasons. Mistakes happen..."
~/soft/minconda3/envs/my-analysis-env/lib/python3.7/site-packages/zfit/core/operations.py in multiply_param_pdf(param, pdf)
86 if pdf.is_extended:
87 raise AlreadyExtendedPDFError()
---> 88 new_pdf = pdf.create_extended(param, name_addition="_autoextended")
89 return new_pdf
90
~/soft/minconda3/envs/my-analysis-env/lib/python3.7/site-packages/zfit/core/basepdf.py in create_extended(self, yield_, name_addition)
462 if self.is_extended:
463 raise AlreadyExtendedPDFError("This PDF is already extended, cannot create an extended one.")
--> 464 new_pdf = self.copy(name=self.name + str(name_addition))
465 new_pdf._set_yield_inplace(value=yield_)
466 return new_pdf
~/soft/minconda3/envs/my-analysis-env/lib/python3.7/site-packages/zfit/core/basepdf.py in copy(self, **override_parameters)
579 # parameters.update(distribution=self.distribution)
580 yield_ = parameters.pop('yield', None)
--> 581 new_instance = type(self)(**parameters)
582 if yield_ is not None:
583 new_instance._set_yield_inplace(yield_)
TypeError: __init__() got an unexpected keyword argument 'c_0'
I have tried also zfit.pdf.Chebyshev().create_extended(Nbkg)
, set normalization and coeff0
parameter for the pdf.
This is in fact a bug that was fixed in version > 0.3.6 (currently develop branch).
You can install the develop branch with the fix doing
pip install git+https://github.com/zfit/zfit