How to use the zfit.models.dist_tfp.Gauss 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_loss.py View on Github external
def create_gauss1():
    mu, sigma = create_params1()
    return Gauss(mu, sigma, obs=obs1, name="gaussian1"), mu, sigma
github zfit / zfit / tests / test_pdfs.py View on Github external
def create_gaussians() -> List[ZfitPDF]:
    # Gauss for sum, same axes
    mu1, mu2, mu3, sigma1, sigma2, sigma3 = create_params()
    gauss1 = Gauss(mu=mu1, sigma=sigma1, obs=obs1, name="gauss1asum")
    gauss2 = Gauss(mu=mu2, sigma=sigma2, obs=obs1, name="gauss2asum")
    gauss3 = Gauss(mu=mu3, sigma=sigma3, obs=obs1, name="gauss3asum")
    gauss_dists = [gauss1, gauss2, gauss3]
    return gauss_dists
github zfit / zfit / tests / test_pdfs.py View on Github external
def product_gauss_4d():
    mu1, mu2, mu3, sigma1, sigma2, sigma3 = create_params("4d")

    obs4 = zfit.Space('obs4', (-4.5, 4.7))
    gauss12 = Gauss(mu=mu1, sigma=sigma1, obs=obs4, name="gauss12a")
    gauss22 = Gauss(mu=mu2, sigma=sigma2, obs=obs1, name="gauss22a")
    gauss32 = Gauss(mu=mu3, sigma=sigma3, obs=obs3, name="gauss32a")
    gauss_dists2 = [gauss12, gauss22, gauss32]
    obs = zfit.Space(['obs1', 'obs2', 'obs3', 'obs4'])

    prod_3d = product_gauss_3d("4d")
    prod_gauss_4d = ProductPDF(pdfs=gauss_dists2 + [prod_3d], obs=obs)
    return prod_gauss_4d
github zfit / zfit / tests / test_basePDF.py View on Github external
def create_wrapped_normal1(nameadd=""):
    mu2, sigma2 = create_mu_sigma_2(nameadd)
    return Gauss(mu=mu2, sigma=sigma2, obs=obs1, name='wrapped_normal1')
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_pdf_normal.py View on Github external
def create_gauss():
    mu1 = Parameter("mu1", mu1_true)
    mu2 = Parameter("mu2", mu2_true)
    mu3 = Parameter("mu3", mu3_true)
    sigma1 = Parameter("sigma1", sigma1_true)
    sigma2 = Parameter("sigma2", sigma2_true)
    sigma3 = Parameter("sigma3", sigma3_true)
    gauss1 = Gauss(mu=mu1, sigma=sigma1, obs=obs1, name="gauss1")
    normal1 = Gauss(mu=mu1, sigma=sigma1, obs=obs1, name="normal1")
    gauss2 = Gauss(mu=mu2, sigma=sigma2, obs=obs1, name="gauss2")
    normal2 = Gauss(mu=mu2, sigma=sigma2, obs=obs1, name="normal2")
    gauss3 = Gauss(mu=mu3, sigma=sigma3, obs=obs1, name="gauss3")
    normal3 = Gauss(mu=mu3, sigma=sigma3, obs=obs1, name="normal3")
    return gauss1, gauss2, gauss3, normal1, normal2, normal3
github zfit / zfit / tests / test_pdf_normal.py View on Github external
def create_gauss():
    mu1 = Parameter("mu1", mu1_true)
    mu2 = Parameter("mu2", mu2_true)
    mu3 = Parameter("mu3", mu3_true)
    sigma1 = Parameter("sigma1", sigma1_true)
    sigma2 = Parameter("sigma2", sigma2_true)
    sigma3 = Parameter("sigma3", sigma3_true)
    gauss1 = Gauss(mu=mu1, sigma=sigma1, obs=obs1, name="gauss1")
    normal1 = Gauss(mu=mu1, sigma=sigma1, obs=obs1, name="normal1")
    gauss2 = Gauss(mu=mu2, sigma=sigma2, obs=obs1, name="gauss2")
    normal2 = Gauss(mu=mu2, sigma=sigma2, obs=obs1, name="normal2")
    gauss3 = Gauss(mu=mu3, sigma=sigma3, obs=obs1, name="gauss3")
    normal3 = Gauss(mu=mu3, sigma=sigma3, obs=obs1, name="normal3")
    return gauss1, gauss2, gauss3, normal1, normal2, normal3
github zfit / zfit / tests / test_pdfs.py View on Github external
def product_gauss_3d(name=""):
    # Gauss for product, independent
    mu1, mu2, mu3, sigma1, sigma2, sigma3 = create_params('3d' + name)

    gauss13 = Gauss(mu=mu1, sigma=sigma1, obs=obs1, name="gauss1a")
    gauss23 = Gauss(mu=mu2, sigma=sigma2, obs=obs2, name="gauss2a")
    gauss33 = Gauss(mu=mu3, sigma=sigma3, obs=obs3, name="gauss3a")
    gauss_dists3 = [gauss13, gauss23, gauss33]
    prod_gauss_3d = ProductPDF(pdfs=gauss_dists3)
    return prod_gauss_3d
github zfit / zfit / tests / test_loss.py View on Github external
def test_add():
    param1 = zfit.Parameter("param1", 1.)
    param2 = zfit.Parameter("param2", 2.)
    param3 = zfit.Parameter("param3", 2.)

    pdfs = [0] * 4
    pdfs[0] = Gauss(param1, 4, obs=obs1)
    pdfs[1] = Gauss(param2, 5, obs=obs1)
    pdfs[2] = Gauss(3, 6, obs=obs1)
    pdfs[3] = Gauss(4, 7, obs=obs1)

    datas = [0] * 4
    datas[0] = z.constant(1.)
    datas[1] = z.constant(2.)
    datas[2] = z.constant(3.)
    datas[3] = z.constant(4.)

    ranges = [0] * 4
    ranges[0] = (1, 4)
    ranges[1] = Space(limits=(2, 5), obs=obs1)
    ranges[2] = Space(limits=(3, 6), obs=obs1)
    ranges[3] = Space(limits=(4, 7), obs=obs1)

    constraint1 = zfit.constraint.nll_gaussian(params=param1, observation=1., uncertainty=0.5)
github zfit / zfit / tests / test_loss.py View on Github external
def test_add():
    param1 = zfit.Parameter("param1", 1.)
    param2 = zfit.Parameter("param2", 2.)
    param3 = zfit.Parameter("param3", 2.)

    pdfs = [0] * 4
    pdfs[0] = Gauss(param1, 4, obs=obs1)
    pdfs[1] = Gauss(param2, 5, obs=obs1)
    pdfs[2] = Gauss(3, 6, obs=obs1)
    pdfs[3] = Gauss(4, 7, obs=obs1)

    datas = [0] * 4
    datas[0] = z.constant(1.)
    datas[1] = z.constant(2.)
    datas[2] = z.constant(3.)
    datas[3] = z.constant(4.)

    ranges = [0] * 4
    ranges[0] = (1, 4)
    ranges[1] = Space(limits=(2, 5), obs=obs1)
    ranges[2] = Space(limits=(3, 6), obs=obs1)
    ranges[3] = Space(limits=(4, 7), obs=obs1)

    constraint1 = zfit.constraint.nll_gaussian(params=param1, observation=1., uncertainty=0.5)
    constraint2 = zfit.constraint.nll_gaussian(params=param3, observation=2., uncertainty=0.25)
    merged_contraints = [constraint1, constraint2]