def test_draw_residual_blh_norm(): np.random.seed(0) data = np.random.randn(1000) blh = BinnedLH(gaussian, data) blh.draw_residual(args=(0., 1.), norm=True) plt.ylim(-4., 3.) plt.xlim(-4., 3.)
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_draw_residual_blh_norm_options(): np.random.seed(0) data = np.random.randn(1000) blh = BinnedLH(gaussian, data) blh.draw_residual(args=(0., 1.), norm=True, color='green', capsize=2, grid=False, zero_line=False)
def test_BinnedLH(self): # write a better test... this depends on subtraction f = gaussian assert_equal(list(describe(f)), ['x', 'mean', 'sigma']) lh = BinnedLH(gaussian, self.data, bound=[-3, 3]) assert_equal(list(describe(lh)), ['mean', 'sigma']) assert_almost_equal(lh(0, 1), 20.446130781601543, 1) minuit = iminuit.Minuit(lh) assert_equal(minuit.errordef, 0.5)
def test_BinnedLH(self): # write a better test... this depends on subtraction f = gaussian assert list(describe(f)) == ["x", "mean", "sigma"] lh = BinnedLH(gaussian, self.data, bound=[-3, 3]) assert list(describe(lh)) == ["mean", "sigma"] assert_allclose(lh(0, 1), 20.446130781601543, atol=1) minuit = iminuit.Minuit(lh) assert_allclose(minuit.errordef, 0.5)
def test_gen_toy2(): pdf = gaussian np.random.seed(0) toy = gen_toy(pdf, 10000, (-5, 5), mean=0, sigma=1) binlh = BinnedLH(pdf, toy, bound=(-5, 5), bins=100) lh = binlh(0., 1.) for x in toy: assert (x < 5) assert (x >= -5) assert_equal(len(toy), 10000) assert (lh / 100. < 1.)
def test_gen_toy2(): pdf = gaussian np.random.seed(0) toy = gen_toy(pdf, 10000, (-5, 5), mean=0, sigma=1) binlh = BinnedLH(pdf, toy, bound=(-5, 5), bins=100) lh = binlh(0.0, 1.0) for x in toy: assert x < 5 assert x >= -5 assert len(toy) == 10000 assert lh / 100.0 < 1.0
def test_draw_blh_extend_residual_norm(): np.random.seed(0) data = np.random.randn(1000) blh = BinnedLH(Extended(gaussian), data, extended=True) blh.draw_residual(args=(0., 1., 1000), norm=True)
def test_draw_residual_blh_norm(): np.random.seed(0) data = np.random.randn(1000) blh = BinnedLH(gaussian, data) blh.draw_residual(args=(0., 1.), norm=True, show_errbars=False)
def test_draw_residual_blh(): np.random.seed(0) data = np.random.randn(1000) blh = BinnedLH(gaussian, data) blh.draw_residual(args=(0., 1.))
def test_draw_blh_extend(): np.random.seed(0) data = np.random.randn(1000) blh = BinnedLH(Extended(gaussian), data, extended=True) blh.draw(args=(0., 1., 1000))
def test_draw_blh(): np.random.seed(0) data = np.random.randn(1000) blh = BinnedLH(gaussian, data) blh.draw(args=(0.0, 1.0))
def test_draw_blh(): np.random.seed(0) data = np.random.randn(1000) blh = BinnedLH(gaussian, data) plt.figure() blh.draw(args=(0., 1.))