Python numpy.histogramdd() Examples

The following are 30 code examples for showing how to use numpy.histogramdd(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module numpy , or try the search function .

Example 1
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 6 votes vote down vote up
def test_rightmost_binedge(self):
        # Test event very close to rightmost binedge. See Github issue #4266
        x = [0.9999999995]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0000000001]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 0.0)
        x = [1.0001]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 0.0) 
Example 2
Project: CausalGAN   Author: mkocaoglu   File: utils.py    License: MIT License 6 votes vote down vote up
def calc_tvd(sess,Generator,Data,N=50000,nbins=10):
    Xd=sess.run(Data.X,{Data.N:N})
    step,Xg=sess.run([Generator.step,Generator.X],{Generator.N:N})

    p_gen,_ = np.histogramdd(Xg,bins=nbins,range=[[0,1],[0,1],[0,1]],normed=True)
    p_dat,_ = np.histogramdd(Xd,bins=nbins,range=[[0,1],[0,1],[0,1]],normed=True)
    p_gen/=nbins**3
    p_dat/=nbins**3
    tvd=0.5*np.sum(np.abs( p_gen-p_dat ))
    mvd=np.max(np.abs( p_gen-p_dat ))

    return step,tvd, mvd

    s_tvd=make_summary(Data.name+'_tvd',tvd)
    s_mvd=make_summary(Data.name+'_mvd',mvd)

    return step,s_tvd,s_mvd
    #return make_summary('tvd/'+Generator.name,tvd) 
Example 3
Project: lambda-packs   Author: ryfeus   File: test_function_base.py    License: MIT License 6 votes vote down vote up
def test_rightmost_binedge(self):
        # Test event very close to rightmost binedge. See Github issue #4266
        x = [0.9999999995]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0000000001]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0001]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 0.0) 
Example 4
Project: auto-alt-text-lambda-api   Author: abhisuri97   File: test_function_base.py    License: MIT License 6 votes vote down vote up
def test_rightmost_binedge(self):
        # Test event very close to rightmost binedge. See Github issue #4266
        x = [0.9999999995]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0000000001]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0001]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 0.0) 
Example 5
Project: vnpy_crypto   Author: birforce   File: test_function_base.py    License: MIT License 6 votes vote down vote up
def test_rightmost_binedge(self):
        # Test event very close to rightmost binedge. See Github issue #4266
        x = [0.9999999995]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0000000001]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0001]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 0.0) 
Example 6
Project: Mastering-Elasticsearch-7.0   Author: PacktPublishing   File: test_histograms.py    License: MIT License 6 votes vote down vote up
def test_rightmost_binedge(self):
        # Test event very close to rightmost binedge. See Github issue #4266
        x = [0.9999999995]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 1.)
        x = [1.0000000001]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 0.0)
        x = [1.0001]
        bins = [[0., 0.5, 1.0]]
        hist, _ = histogramdd(x, bins=bins)
        assert_(hist[0] == 0.0)
        assert_(hist[1] == 0.0) 
Example 7
Project: differential-privacy-library   Author: IBM   File: test_histogramdd.py    License: MIT License 5 votes vote down vote up
def test_no_params(self):
        a = np.array([1, 2, 3, 4, 5])
        with self.assertWarns(PrivacyLeakWarning):
            res = histogramdd(a)
        self.assertIsNotNone(res) 
Example 8
Project: differential-privacy-library   Author: IBM   File: test_histogramdd.py    License: MIT License 5 votes vote down vote up
def test_no_range(self):
        a = np.array([1, 2, 3, 4, 5])
        with self.assertWarns(PrivacyLeakWarning):
            res = histogramdd(a, epsilon=2)
        self.assertIsNotNone(res) 
Example 9
Project: differential-privacy-library   Author: IBM   File: test_histogramdd.py    License: MIT License 5 votes vote down vote up
def test_same_edges(self):
        a = np.array([1, 2, 3, 4, 5])
        _, edges = np.histogramdd(a, bins=3, range=[(0, 10)])
        _, dp_edges = histogramdd(a, epsilon=1, bins=3, range=[(0, 10)])

        for i in range(len(edges)):
            self.assertTrue((edges[i] == dp_edges[i]).all()) 
Example 10
Project: differential-privacy-library   Author: IBM   File: test_histogramdd.py    License: MIT License 5 votes vote down vote up
def test_different_result(self):
        global_seed(3141592653)
        a = np.array([1, 2, 3, 4, 5])
        hist, _ = np.histogramdd(a, bins=3, range=[(0, 10)])
        dp_hist, _ = histogramdd(a, epsilon=0.1, bins=3, range=[(0, 10)])

        # print("Non-private histogram: %s" % hist)
        # print("Private histogram: %s" % dp_hist)
        self.assertTrue((hist != dp_hist).any()) 
Example 11
Project: differential-privacy-library   Author: IBM   File: test_histogramdd.py    License: MIT License 5 votes vote down vote up
def test_density_1d(self):
        global_seed(3141592653)
        a = np.array([1, 2, 3, 4, 5])
        dp_hist, _ = histogramdd(a, epsilon=1, bins=3, range=[(0, 10)], density=True)

        # print(dp_hist.sum())

        self.assertAlmostEqual(dp_hist.sum(), 1.0 * 3 / 10) 
Example 12
Project: differential-privacy-library   Author: IBM   File: test_histogramdd.py    License: MIT License 5 votes vote down vote up
def test_accountant(self):
        acc = BudgetAccountant(1.5, 0)

        a = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]).T
        histogramdd(a, epsilon=1, bins=3, range=[(0, 10), (0, 10)], density=True, accountant=acc)

        with self.assertRaises(BudgetError):
            histogramdd(a, epsilon=1, bins=3, range=[(0, 10), (0, 10)], density=True, accountant=acc) 
Example 13
Project: differential-privacy-library   Author: IBM   File: test_histogramdd.py    License: MIT License 5 votes vote down vote up
def test_default_accountant(self):
        BudgetAccountant.pop_default()

        a = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]).T
        histogramdd(a, epsilon=1, bins=3, range=[(0, 10), (0, 10)], density=True)
        acc = BudgetAccountant.pop_default()
        self.assertEqual((1, 0), acc.total())
        self.assertEqual(acc.epsilon, float("inf"))
        self.assertEqual(acc.delta, 1.0)

        histogramdd(a, epsilon=1, bins=3, range=[(0, 10), (0, 10)])

        self.assertEqual((1, 0), acc.total()) 
Example 14
Project: recruit   Author: Frank-qlu   File: test_regression.py    License: Apache License 2.0 5 votes vote down vote up
def test_histogramdd_too_many_bins(self):
        # Ticket 928.
        assert_raises(ValueError, np.histogramdd, np.ones((1, 10)), bins=2**10) 
Example 15
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_simple(self):
        x = np.array([[-.5, .5, 1.5], [-.5, 1.5, 2.5], [-.5, 2.5, .5],
                      [.5,  .5, 1.5], [.5,  1.5, 2.5], [.5,  2.5, 2.5]])
        H, edges = histogramdd(x, (2, 3, 3),
                               range=[[-1, 1], [0, 3], [0, 3]])
        answer = np.array([[[0, 1, 0], [0, 0, 1], [1, 0, 0]],
                           [[0, 1, 0], [0, 0, 1], [0, 0, 1]]])
        assert_array_equal(H, answer)

        # Check normalization
        ed = [[-2, 0, 2], [0, 1, 2, 3], [0, 1, 2, 3]]
        H, edges = histogramdd(x, bins=ed, density=True)
        assert_(np.all(H == answer / 12.))

        # Check that H has the correct shape.
        H, edges = histogramdd(x, (2, 3, 4),
                               range=[[-1, 1], [0, 3], [0, 4]],
                               density=True)
        answer = np.array([[[0, 1, 0, 0], [0, 0, 1, 0], [1, 0, 0, 0]],
                           [[0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 1, 0]]])
        assert_array_almost_equal(H, answer / 6., 4)
        # Check that a sequence of arrays is accepted and H has the correct
        # shape.
        z = [np.squeeze(y) for y in np.split(x, 3, axis=1)]
        H, edges = histogramdd(
            z, bins=(4, 3, 2), range=[[-2, 2], [0, 3], [0, 2]])
        answer = np.array([[[0, 0], [0, 0], [0, 0]],
                           [[0, 1], [0, 0], [1, 0]],
                           [[0, 1], [0, 0], [0, 0]],
                           [[0, 0], [0, 0], [0, 0]]])
        assert_array_equal(H, answer)

        Z = np.zeros((5, 5, 5))
        Z[list(range(5)), list(range(5)), list(range(5))] = 1.
        H, edges = histogramdd([np.arange(5), np.arange(5), np.arange(5)], 5)
        assert_array_equal(H, Z) 
Example 16
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_shape_3d(self):
        # All possible permutations for bins of different lengths in 3D.
        bins = ((5, 4, 6), (6, 4, 5), (5, 6, 4), (4, 6, 5), (6, 5, 4),
                (4, 5, 6))
        r = np.random.rand(10, 3)
        for b in bins:
            H, edges = histogramdd(r, b)
            assert_(H.shape == b) 
Example 17
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_shape_4d(self):
        # All possible permutations for bins of different lengths in 4D.
        bins = ((7, 4, 5, 6), (4, 5, 7, 6), (5, 6, 4, 7), (7, 6, 5, 4),
                (5, 7, 6, 4), (4, 6, 7, 5), (6, 5, 7, 4), (7, 5, 4, 6),
                (7, 4, 6, 5), (6, 4, 7, 5), (6, 7, 5, 4), (4, 6, 5, 7),
                (4, 7, 5, 6), (5, 4, 6, 7), (5, 7, 4, 6), (6, 7, 4, 5),
                (6, 5, 4, 7), (4, 7, 6, 5), (4, 5, 6, 7), (7, 6, 4, 5),
                (5, 4, 7, 6), (5, 6, 7, 4), (6, 4, 5, 7), (7, 5, 6, 4))

        r = np.random.rand(10, 4)
        for b in bins:
            H, edges = histogramdd(r, b)
            assert_(H.shape == b) 
Example 18
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_weights(self):
        v = np.random.rand(100, 2)
        hist, edges = histogramdd(v)
        n_hist, edges = histogramdd(v, density=True)
        w_hist, edges = histogramdd(v, weights=np.ones(100))
        assert_array_equal(w_hist, hist)
        w_hist, edges = histogramdd(v, weights=np.ones(100) * 2, density=True)
        assert_array_equal(w_hist, n_hist)
        w_hist, edges = histogramdd(v, weights=np.ones(100, int) * 2)
        assert_array_equal(w_hist, 2 * hist) 
Example 19
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_empty(self):
        a, b = histogramdd([[], []], bins=([0, 1], [0, 1]))
        assert_array_max_ulp(a, np.array([[0.]]))
        a, b = np.histogramdd([[], [], []], bins=2)
        assert_array_max_ulp(a, np.zeros((2, 2, 2))) 
Example 20
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_bins_errors(self):
        # There are two ways to specify bins. Check for the right errors
        # when mixing those.
        x = np.arange(8).reshape(2, 4)
        assert_raises(ValueError, np.histogramdd, x, bins=[-1, 2, 4, 5])
        assert_raises(ValueError, np.histogramdd, x, bins=[1, 0.99, 1, 1])
        assert_raises(
            ValueError, np.histogramdd, x, bins=[1, 1, 1, [1, 2, 3, -3]])
        assert_(np.histogramdd(x, bins=[1, 1, 1, [1, 2, 3, 4]])) 
Example 21
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_inf_edges(self):
        # Test using +/-inf bin edges works. See #1788.
        with np.errstate(invalid='ignore'):
            x = np.arange(6).reshape(3, 2)
            expected = np.array([[1, 0], [0, 1], [0, 1]])
            h, e = np.histogramdd(x, bins=[3, [-np.inf, 2, 10]])
            assert_allclose(h, expected)
            h, e = np.histogramdd(x, bins=[3, np.array([-1, 2, np.inf])])
            assert_allclose(h, expected)
            h, e = np.histogramdd(x, bins=[3, [-np.inf, 3, np.inf]])
            assert_allclose(h, expected) 
Example 22
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_finite_range(self):
        vals = np.random.random((100, 3))
        histogramdd(vals, range=[[0.0, 1.0], [0.25, 0.75], [0.25, 0.5]])
        assert_raises(ValueError, histogramdd, vals,
                      range=[[0.0, 1.0], [0.25, 0.75], [0.25, np.inf]])
        assert_raises(ValueError, histogramdd, vals,
                      range=[[0.0, 1.0], [np.nan, 0.75], [0.25, 0.5]]) 
Example 23
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_edge_dtype(self):
        """ Test that if an edge array is input, its type is preserved """
        x = np.array([0, 10, 20])
        y = x / 10
        x_edges = np.array([0, 5, 15, 20])
        y_edges = x_edges / 10
        hist, edges = histogramdd((x, y), bins=(x_edges, y_edges))

        assert_equal(edges[0].dtype, x_edges.dtype)
        assert_equal(edges[1].dtype, y_edges.dtype) 
Example 24
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_large_integers(self):
        big = 2**60  # Too large to represent with a full precision float

        x = np.array([0], np.int64)
        x_edges = np.array([-1, +1], np.int64)
        y = big + x
        y_edges = big + x_edges

        hist, edges = histogramdd((x, y), bins=(x_edges, y_edges))

        assert_equal(hist[0, 0], 1) 
Example 25
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_density_non_uniform_2d(self):
        # Defines the following grid:
        #
        #    0 2     8
        #   0+-+-----+
        #    + |     +
        #    + |     +
        #   6+-+-----+
        #   8+-+-----+
        x_edges = np.array([0, 2, 8])
        y_edges = np.array([0, 6, 8])
        relative_areas = np.array([
            [3, 9],
            [1, 3]])

        # ensure the number of points in each region is proportional to its area
        x = np.array([1] + [1]*3 + [7]*3 + [7]*9)
        y = np.array([7] + [1]*3 + [7]*3 + [1]*9)

        # sanity check that the above worked as intended
        hist, edges = histogramdd((y, x), bins=(y_edges, x_edges))
        assert_equal(hist, relative_areas)

        # resulting histogram should be uniform, since counts and areas are propotional
        hist, edges = histogramdd((y, x), bins=(y_edges, x_edges), density=True)
        assert_equal(hist, 1 / (8*8)) 
Example 26
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_density_non_uniform_1d(self):
        # compare to histogram to show the results are the same
        v = np.arange(10)
        bins = np.array([0, 1, 3, 6, 10])
        hist, edges = histogram(v, bins, density=True)
        hist_dd, edges_dd = histogramdd((v,), (bins,), density=True)
        assert_equal(hist, hist_dd)
        assert_equal(edges, edges_dd[0]) 
Example 27
Project: recruit   Author: Frank-qlu   File: test_histograms.py    License: Apache License 2.0 5 votes vote down vote up
def test_density_via_normed(self):
        # normed should simply alias to density argument
        v = np.arange(10)
        bins = np.array([0, 1, 3, 6, 10])
        hist, edges = histogram(v, bins, density=True)
        hist_dd, edges_dd = histogramdd((v,), (bins,), normed=True)
        assert_equal(hist, hist_dd)
        assert_equal(edges, edges_dd[0]) 
Example 28
Project: westpa   Author: westpa   File: __main__.py    License: MIT License 5 votes vote down vote up
def _test_double(npts=1024*1024,loops=3):
    from time import time
    mine_times = [None]*loops
    theirs_times = [None]*loops

    # though 1.0 should be sufficient, weirdness in the boundary conditions
    # for numpy.digitize appears to introduce a discrepancy, so throw something
    # greater than 1.0 in for good measure
    binbounds = [[0,0.5,1,1.1] for x in range(3)]
    weights = numpy.random.rand(npts)
    #weights = numpy.ones((npts,), dtype=numpy.float64)
    for n in range(loops):
        testdat = numpy.random.rand(npts,3)
        mstart = time()
        mine = histnd(testdat, binbounds, weights=weights)
        mstop = time()
        tstart = time()
        theirs = numpy.histogramdd(testdat, binbounds, weights=weights)[0]
        tstop = time()
        mine_times[n] = mstop-mstart
        theirs_times[n] = tstop-tstart
        print(mine)
        print(theirs)
        errsum = numpy.abs(mine-theirs).sum()
        errsum_per_item = errsum / npts
        rel_err = errsum / numpy.abs(weights).sum()
        print('sum of the absolute errors: {} ({} relative, {} per entry)'.format(errsum, rel_err, errsum_per_item))

    print('mine, best of {}:   {}'.format(loops, min(mine_times)))
    print('theirs, best of {}: {}'.format(loops, min(theirs_times))) 
Example 29
Project: westpa   Author: westpa   File: __main__.py    License: MIT License 5 votes vote down vote up
def _test_float(npts=1024*1024,ndim=3,loops=3):
    from time import time
    mine_times = [None]*loops
    theirs_times = [None]*loops
    
    binbounds = [[0,0.5,1,1.1] for x in range(ndim)]
    #weights = numpy.random.rand(npts)
    weights = numpy.ones((npts,), dtype=numpy.float64)
    for n in range(loops):
        testdat = numpy.require(numpy.random.rand(npts,ndim), numpy.float32)
        print(testdat)
        mstart = time()
        mine = histnd(testdat, binbounds, weights=weights)
        mstop = time()
        tstart = time()
        theirs = numpy.histogramdd(testdat, binbounds, weights=weights)[0]
        tstop = time()
        mine_times[n] = mstop-mstart
        theirs_times[n] = tstop-tstart
        print(mine)
        print(theirs)
        errsum = numpy.abs(mine-theirs).sum()
        errsum_per_item = errsum / npts
        rel_err = errsum / numpy.abs(weights).sum()
        print('sum of the absolute errors: {} ({} relative, {} per entry)'.format(errsum, rel_err, errsum_per_item))

    print('mine, best of {}:   {}'.format(loops, min(mine_times)))
    print('theirs, best of {}: {}'.format(loops, min(theirs_times))) 
Example 30
Project: westpa   Author: westpa   File: __main__.py    License: MIT License 5 votes vote down vote up
def _test_uint(npts=1024*1024,ndim=3,loops=3):
    from time import time
    mine_times = [None]*loops
    theirs_times = [None]*loops
    
    binbounds = [[0,1,2,3,4] for x in range(ndim)]
    #weights = numpy.random.rand(npts)
    weights = numpy.ones((npts,), dtype=numpy.float64)
    print('binbounds: {}'.format(binbounds))
    print('weights')
    print(weights)
    for n in range(loops):
        testdat = numpy.require(numpy.random.randint(0,4,size=(npts,ndim)), numpy.uint16)
        print('test data')
        print(testdat)
        mstart = time()
        mine = histnd(testdat, binbounds, weights=weights)
        mstop = time()
        tstart = time()
        theirs = numpy.histogramdd(testdat, binbounds, weights=weights)[0]
        tstop = time()
        mine_times[n] = mstop-mstart
        theirs_times[n] = tstop-tstart
        print(mine)
        print(theirs)
        errsum = numpy.abs(mine-theirs).sum()
        errsum_per_item = errsum / npts
        rel_err = errsum / numpy.abs(weights).sum()
        print('sum of the absolute errors: {} ({} relative, {} per entry)'.format(errsum, rel_err, errsum_per_item))

    print('mine, best of {}:   {}'.format(loops, min(mine_times)))
    print('theirs, best of {}: {}'.format(loops, min(theirs_times)))