def test_bx2_with_parts(): np.random.seed(0) data = np.random.randn(10000) shifted = data + 3. data = np.append(data, [shifted]) g1 = Extended(rename(gaussian, ['x', 'lmu', 'lsigma']), extname='N1') g2 = Extended(rename(gaussian, ['x', 'rmu', 'rsigma']), extname='N2') allpdf = AddPdf(g1, g2) bx2 = BinnedChi2(allpdf, data) bx2.draw(args=(0, 1, 10000, 3, 1, 10000), parts=True)
def test_draw_simultaneous(): np.random.seed(0) data = np.random.randn(10000) shifted = data + 3. g1 = rename(gaussian, ['x', 'lmu', 'sigma']) g2 = rename(gaussian, ['x', 'rmu', 'sigma']) ulh1 = UnbinnedLH(g1, data) ulh2 = UnbinnedLH(g2, shifted) sim = SimultaneousFit(ulh1, ulh2) sim.draw(args=(0, 1, 3))
def test_bx2_with_parts(): np.random.seed(0) data = np.random.randn(10000) shifted = data + 3.0 data = np.append(data, [shifted]) g1 = Extended(rename(gaussian, ["x", "lmu", "lsigma"]), extname="N1") g2 = Extended(rename(gaussian, ["x", "rmu", "rsigma"]), extname="N2") allpdf = AddPdf(g1, g2) bx2 = BinnedChi2(allpdf, data) bx2.draw(args=(0, 1, 10000, 3, 1, 10000), parts=True)
def test_blh_with_parts(): np.random.seed(0) data = np.random.randn(10000) shifted = data + 3. data = np.append(data, [shifted]) g1 = rename(gaussian, ['x', 'lmu', 'lsigma']) g2 = rename(gaussian, ['x', 'rmu', 'rsigma']) allpdf = AddPdfNorm(g1, g2) blh = BinnedLH(allpdf, data) blh.draw(args=(0, 1, 3, 1, 0.5), parts=True)
def test_ulh_with_parts(): np.random.seed(0) data = np.random.randn(10000) shifted = data + 3.0 data = np.append(data, [shifted]) g1 = rename(gaussian, ["x", "lmu", "lsigma"]) g2 = rename(gaussian, ["x", "rmu", "rsigma"]) allpdf = AddPdfNorm(g1, g2) ulh = UnbinnedLH(allpdf, data) ulh.draw(args=(0, 1, 3, 1, 0.5), parts=True)
def test_draw_simultaneous_prefix(): np.random.seed(0) data = np.random.randn(10000) shifted = data + 3. g1 = rename(gaussian, ['x', 'lmu', 'sigma']) g2 = rename(gaussian, ['x', 'rmu', 'sigma']) ulh1 = UnbinnedLH(g1, data) ulh2 = UnbinnedLH(g2, shifted) sim = SimultaneousFit(ulh1, ulh2, prefix=['g1_', 'g2_']) minuit = Minuit(sim, g1_lmu=0., g1_sigma=1., g2_rmu=0., g2_sigma=1., print_level=0) minuit.migrad() sim.draw(minuit)
def test_draw_simultaneous_prefix(): np.random.seed(0) data = np.random.randn(10000) shifted = data + 3.0 g1 = rename(gaussian, ["x", "lmu", "sigma"]) g2 = rename(gaussian, ["x", "rmu", "sigma"]) ulh1 = UnbinnedLH(g1, data) ulh2 = UnbinnedLH(g2, shifted) sim = SimultaneousFit(ulh1, ulh2, prefix=["g1_", "g2_"]) minuit = Minuit( sim, g1_lmu=0.0, g1_sigma=1.0, g2_rmu=0.0, g2_sigma=1.0, print_level=0 ) minuit.migrad() sim.draw(minuit)
def test_simultaneous(self): np.random.seed(0) data = np.random.randn(10000) shifted = data + 3. g1 = rename(gaussian, ['x', 'lmu', 'sigma']) g2 = rename(gaussian, ['x', 'rmu', 'sigma']) ulh1 = UnbinnedLH(g1, data) ulh2 = UnbinnedLH(g2, shifted) sim = SimultaneousFit(ulh1, ulh2) assert describe(sim) == ['lmu', 'sigma', 'rmu'] minuit = iminuit.Minuit(sim, sigma=1.2, pedantic=False, print_level=0) minuit.migrad() assert minuit.migrad_ok() assert_allclose(minuit.values['lmu'], 0., atol=2 * minuit.errors['lmu']) assert_allclose(minuit.values['rmu'], 3., atol=2 * minuit.errors['rmu']) assert_allclose(minuit.values['sigma'], 1., atol=2 * minuit.errors['sigma'])
def test_simultaneous(self): np.random.seed(0) data = np.random.randn(10000) shifted = data + 3. g1 = rename(gaussian, ['x', 'lmu', 'sigma']) g2 = rename(gaussian, ['x', 'rmu', 'sigma']) ulh1 = UnbinnedLH(g1, data) ulh2 = UnbinnedLH(g2, shifted) sim = SimultaneousFit(ulh1, ulh2) assert_equal(describe(sim), ['lmu', 'sigma', 'rmu']) minuit = iminuit.Minuit(sim, sigma=1.2, pedantic=False, print_level=0) minuit.migrad() assert (minuit.migrad_ok()) assert_almost_equal(minuit.values['lmu'], 0., delta=2 * minuit.errors['lmu']) assert_almost_equal(minuit.values['rmu'], 3., delta=2 * minuit.errors['rmu']) assert_almost_equal(minuit.values['sigma'], 1., delta=2 * minuit.errors['sigma'])
def test_simultaneous(self): np.random.seed(0) data = np.random.randn(10000) shifted = data + 3.0 g1 = rename(gaussian, ["x", "lmu", "sigma"]) g2 = rename(gaussian, ["x", "rmu", "sigma"]) ulh1 = UnbinnedLH(g1, data) ulh2 = UnbinnedLH(g2, shifted) sim = SimultaneousFit(ulh1, ulh2) assert describe(sim) == ["lmu", "sigma", "rmu"] minuit = iminuit.Minuit(sim, sigma=1.2, pedantic=False, print_level=0) minuit.migrad() assert minuit.migrad_ok() assert_allclose(minuit.values["lmu"], 0.0, atol=2 * minuit.errors["lmu"]) assert_allclose(minuit.values["rmu"], 3.0, atol=2 * minuit.errors["rmu"]) assert_allclose(minuit.values["sigma"], 1.0, atol=2 * minuit.errors["sigma"])