How to use the zfit.core.parameter.Parameter function in zfit

To help you get started, we’ve selected a few zfit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zfit / zfit / tests / test_pdfs.py View on Github external
def test_extended_gauss():
    mu1 = Parameter("mu11", 1.)
    mu2 = Parameter("mu21", 12.)
    mu3 = Parameter("mu31", 3.)
    sigma1 = Parameter("sigma11", 1.)
    sigma2 = Parameter("sigma21", 12.)
    sigma3 = Parameter("sigma31", 33.)
    yield1 = Parameter("yield11", 150.)
    yield2 = Parameter("yield21", 550.)
    yield3 = Parameter("yield31", 2500.)

    gauss1 = Gauss(mu=mu1, sigma=sigma1, obs=obs1, name="gauss11")
    gauss2 = Gauss(mu=mu2, sigma=sigma2, obs=obs1, name="gauss21")
    gauss3 = Gauss(mu=mu3, sigma=sigma3, obs=obs1, name="gauss31")
    gauss1 = gauss1.create_extended(yield1)
    gauss2 = gauss2.create_extended(yield2)
    gauss3 = gauss3.create_extended(yield3)

    gauss_dists = [gauss1, gauss2, gauss3]
github zfit / zfit / tests / test_basePDF.py View on Github external
def create_gauss3(nameadd=""):
    mu3 = Parameter("mu3" + nameadd, mu_true, mu_true - 2., mu_true + 7.)
    sigma3 = Parameter("sigma3" + nameadd, sigma_true, sigma_true - 10., sigma_true + 5.)
    gauss3 = zfit.pdf.Gauss(mu=mu3, sigma=sigma3, obs=obs1)
    return gauss3
github zfit / zfit / tests / test_basePDF.py View on Github external
def create_gauss1(nameadd=""):
    mu = Parameter("mu" + nameadd, mu_true, mu_true - 2., mu_true + 7.)
    sigma = Parameter("sigma" + nameadd, sigma_true, sigma_true - 10., sigma_true + 5.)

    gauss_params1 = Gauss(mu=mu, sigma=sigma, obs=obs1, name="gauss_params1")
    return gauss_params1
github zfit / zfit / tests / test_pdfs.py View on Github external
def test_extended_gauss():
    mu1 = Parameter("mu11", 1.)
    mu2 = Parameter("mu21", 12.)
    mu3 = Parameter("mu31", 3.)
    sigma1 = Parameter("sigma11", 1.)
    sigma2 = Parameter("sigma21", 12.)
    sigma3 = Parameter("sigma31", 33.)
    yield1 = Parameter("yield11", 150.)
    yield2 = Parameter("yield21", 550.)
    yield3 = Parameter("yield31", 2500.)

    gauss1 = Gauss(mu=mu1, sigma=sigma1, obs=obs1, name="gauss11")
    gauss2 = Gauss(mu=mu2, sigma=sigma2, obs=obs1, name="gauss21")
    gauss3 = Gauss(mu=mu3, sigma=sigma3, obs=obs1, name="gauss31")
    gauss1 = gauss1.create_extended(yield1)
    gauss2 = gauss2.create_extended(yield2)
    gauss3 = gauss3.create_extended(yield3)

    gauss_dists = [gauss1, gauss2, gauss3]

    sum_gauss = SumPDF(pdfs=gauss_dists)
    integral_true = sum_gauss.integrate((-1, 5)) * sum_gauss.get_yield()
github zfit / zfit / tests / test_basePDF.py View on Github external
def create_gauss1(nameadd=""):
    mu = Parameter("mu" + nameadd, mu_true, mu_true - 2., mu_true + 7.)
    sigma = Parameter("sigma" + nameadd, sigma_true, sigma_true - 10., sigma_true + 5.)

    gauss_params1 = Gauss(mu=mu, sigma=sigma, obs=obs1, name="gauss_params1")
    return gauss_params1
github zfit / zfit / tests / test_pdfs.py View on Github external
def test_extended_gauss():
    mu1 = Parameter("mu11", 1.)
    mu2 = Parameter("mu21", 12.)
    mu3 = Parameter("mu31", 3.)
    sigma1 = Parameter("sigma11", 1.)
    sigma2 = Parameter("sigma21", 12.)
    sigma3 = Parameter("sigma31", 33.)
    yield1 = Parameter("yield11", 150.)
    yield2 = Parameter("yield21", 550.)
    yield3 = Parameter("yield31", 2500.)

    gauss1 = Gauss(mu=mu1, sigma=sigma1, obs=obs1, name="gauss11")
    gauss2 = Gauss(mu=mu2, sigma=sigma2, obs=obs1, name="gauss21")
    gauss3 = Gauss(mu=mu3, sigma=sigma3, obs=obs1, name="gauss31")
    gauss1 = gauss1.create_extended(yield1)
    gauss2 = gauss2.create_extended(yield2)
    gauss3 = gauss3.create_extended(yield3)

    gauss_dists = [gauss1, gauss2, gauss3]

    sum_gauss = SumPDF(pdfs=gauss_dists)
    integral_true = sum_gauss.integrate((-1, 5)) * sum_gauss.get_yield()

    assert zfit.run(integral_true) == pytest.approx(zfit.run(sum_gauss.ext_integrate((-1, 5))))
    normalization_testing(pdf=sum_gauss, limits=obs1)
github zfit / zfit / tests / test_integrate.py View on Github external
def test_analytic_integral():
    class DistFunc3(zbasepdf.BasePDF):
        def _unnormalized_pdf(self, x):
            return func3_2deps(x)

    mu_true = 1.4
    sigma_true = 1.8
    limits = -4.3, 1.9
    mu = Parameter("mu_1414", mu_true, mu_true - 2., mu_true + 7.)
    sigma = Parameter("sigma_1414", sigma_true, sigma_true - 10., sigma_true + 5.)
    gauss_params1 = CustomGaussOLD(mu=mu, sigma=sigma, obs=obs1, name="gauss_params1")
    normal_params1 = Gauss(mu=mu, sigma=sigma, obs=obs1, name="gauss_params1")
    try:
        infinity = mt.inf
    except AttributeError:  # py34
        infinity = float('inf')
    gauss_integral_infs = gauss_params1.integrate(limits=(-8 * sigma_true, 8 * sigma_true), norm_range=False)
    normal_integral_infs = normal_params1.integrate(limits=(-8 * sigma_true, 8 * sigma_true), norm_range=False)

    DistFunc3.register_analytic_integral(func=func3_2deps_fully_integrated,
                                         limits=Space(limits=limits3, axes=(0, 1)))

    dist_func3 = DistFunc3(obs=['obs1', 'obs2'])
    normal_integral_infs = normal_integral_infs
    func3_integrated = dist_func3.integrate(limits=Space(limits=limits3, axes=(0, 1)),
github zfit / zfit / zfit / core / parameter.py View on Github external
if value.dtype.is_complex:
        if name is None:
            name = "FIXED_complex_autoparam_" + str(get_auto_number())
        if prefer_constant:
            raise WorkInProgressError("Constant complex param not here yet, complex Mixin?")
        value = ComplexParameter(name, value_fn=value, floating=not prefer_constant)

    else:
        if prefer_constant:
            if name is None:
                name = "FIXED_autoparam_" + str(get_auto_number()) if name is None else name
            value = ConstantParameter(name, value=value)

        else:
            name = "autoparam_" + str(get_auto_number()) if name is None else name
            value = Parameter(name=name, value=value)

    return value
github zfit / zfit / zfit / util / diverse.py View on Github external
def __init__(self, prefix, n, ranges):  # TODO: ranges? x_range, y_range?
        self.params = []
        for i in range(n):
            norm = Parameter(prefix + "n{:d}".format(i), 1. / (1. + float(i)), 0., 2.)
            xmean = Parameter(prefix + "xm{:d}".format(i),
                              np.random.uniform(x_range[0], x_range[1], 1)[0], -1., 1.)
            ymean = Parameter(prefix + "ym{:d}".format(i),
                              np.random.uniform(y_range[0], y_range[1], 1)[0], -1., 1.)
            xsigma = Parameter(prefix + "xs{:d}".format(i),
                               (x_range[1] - x_range[0]) / 4., 0., 2.)
            ysigma = Parameter(prefix + "ys{:d}".format(i),
                               (x_range[1] - x_range[0]) / 4., 0., 2.)
            corr = Parameter(prefix + "c{:d}".format(i), 0., -0.9, 0.9)
            self.params += [(norm, xmean, ymean, xsigma, ysigma, corr)]
        self.params[0][0].step_size = 0.  # Fix first normalisation term