Esempio n. 1
0
    def test_quartile_estimation(self):
        counts = numpy.array([1, 3, 6, 10, 7, 2, 1])
        edges = numpy.array(range(len(counts) + 1))
        quartiles = [0, 0.25, 0.5, 0.75, 1]
        est = _estimate_percentiles_from_distrib(counts,
                                                 edges,
                                                 percentiles=quartiles)
        exp = [0.5, 2.08333333, 3., 3.85714286, 6.5]
        assert numpy.allclose(est, exp)

        counts = numpy.array(
            [counts, [10, 5, 4, 3, 1, 1, 1], [1, 1, 1, 2, 3, 5, 10]])
        # edges = numpy.arange(counts.shape[1])
        est = _estimate_percentiles_from_distrib(counts,
                                                 edges,
                                                 percentiles=quartiles)
        exp = [exp, [0.5, 0.5, 1., 2.4375, 6.5], [0.5, 3.75, 5.2, 5.925, 6.5]]
        assert numpy.allclose(exp, est)

        counts = counts.T
        est = _estimate_percentiles_from_distrib(counts,
                                                 edges,
                                                 percentiles=quartiles,
                                                 samples_in_rows=False)
        assert numpy.allclose(est, numpy.array(exp).T)
Esempio n. 2
0
    def test_quartile_estimation(self):
        counts = numpy.array([1, 3, 6, 10, 7, 2, 1])
        edges = numpy.array(range(len(counts) + 1))
        quartiles = [0, 0.25, 0.5, 0.75, 1]
        est = _estimate_percentiles_from_distrib(counts, edges, percentiles=quartiles)
        exp = [0.5, 2.08333333, 3.0, 3.85714286, 6.5]
        assert numpy.allclose(est, exp)

        counts = numpy.array([counts, [10, 5, 4, 3, 1, 1, 1], [1, 1, 1, 2, 3, 5, 10]])
        # edges = numpy.arange(counts.shape[1])
        est = _estimate_percentiles_from_distrib(counts, edges, percentiles=quartiles)
        exp = [exp, [0.5, 0.5, 1.0, 2.4375, 6.5], [0.5, 3.75, 5.2, 5.925, 6.5]]
        assert numpy.allclose(exp, est)

        counts = counts.T
        est = _estimate_percentiles_from_distrib(counts, edges, percentiles=quartiles, samples_in_rows=False)
        assert numpy.allclose(est, numpy.array(exp).T)