コード例 #1
0
ファイル: test_rank.py プロジェクト: eelcovv/pywafo
    def test_basic(self):
        """Check a few basic examples of the tie correction factor."""
        # One tie of two elements
        ranks = np.array([1.0, 2.5, 2.5])
        c = tiecorrect(ranks)
        T = 2.0
        N = ranks.size
        expected = 1.0 - (T ** 3 - T) / (N ** 3 - N)
        assert_equal(c, expected)

        # One tie of two elements (same as above, but tie is not at the end)
        ranks = np.array([1.5, 1.5, 3.0])
        c = tiecorrect(ranks)
        T = 2.0
        N = ranks.size
        expected = 1.0 - (T ** 3 - T) / (N ** 3 - N)
        assert_equal(c, expected)

        # One tie of three elements
        ranks = np.array([1.0, 3.0, 3.0, 3.0])
        c = tiecorrect(ranks)
        T = 3.0
        N = ranks.size
        expected = 1.0 - (T ** 3 - T) / (N ** 3 - N)
        assert_equal(c, expected)

        # Two ties, lengths 2 and 3.
        ranks = np.array([1.5, 1.5, 4.0, 4.0, 4.0])
        c = tiecorrect(ranks)
        T1 = 2.0
        T2 = 3.0
        N = ranks.size
        expected = 1.0 - ((T1 ** 3 - T1) + (T2 ** 3 - T2)) / (N ** 3 - N)
        assert_equal(c, expected)
コード例 #2
0
    def test_basic(self):
        """Check a few basic examples of the tie correction factor."""
        # One tie of two elements
        ranks = np.array([1.0, 2.5, 2.5])
        c = tiecorrect(ranks)
        T = 2.0
        N = ranks.size
        expected = 1.0 - (T**3 - T) / (N**3 - N)
        assert_equal(c, expected)

        # One tie of two elements (same as above, but tie is not at the end)
        ranks = np.array([1.5, 1.5, 3.0])
        c = tiecorrect(ranks)
        T = 2.0
        N = ranks.size
        expected = 1.0 - (T**3 - T) / (N**3 - N)
        assert_equal(c, expected)

        # One tie of three elements
        ranks = np.array([1.0, 3.0, 3.0, 3.0])
        c = tiecorrect(ranks)
        T = 3.0
        N = ranks.size
        expected = 1.0 - (T**3 - T) / (N**3 - N)
        assert_equal(c, expected)

        # Two ties, lengths 2 and 3.
        ranks = np.array([1.5, 1.5, 4.0, 4.0, 4.0])
        c = tiecorrect(ranks)
        T1 = 2.0
        T2 = 3.0
        N = ranks.size
        expected = 1.0 - ((T1**3 - T1) + (T2**3 - T2)) / (N**3 - N)
        assert_equal(c, expected)
コード例 #3
0
 def test_no_correction(self):
     """Arrays with no ties require no correction."""
     ranks = np.arange(2.0)
     c = tiecorrect(ranks)
     assert_equal(c, 1.0)
     ranks = np.arange(3.0)
     c = tiecorrect(ranks)
     assert_equal(c, 1.0)
コード例 #4
0
ファイル: test_rank.py プロジェクト: eelcovv/pywafo
 def test_no_correction(self):
     """Arrays with no ties require no correction."""
     ranks = np.arange(2.0)
     c = tiecorrect(ranks)
     assert_equal(c, 1.0)
     ranks = np.arange(3.0)
     c = tiecorrect(ranks)
     assert_equal(c, 1.0)
コード例 #5
0
 def test_empty(self):
     """An empty array requires no correction, should return 1.0."""
     ranks = np.array([], dtype=np.float64)
     c = tiecorrect(ranks)
     assert_equal(c, 1.0)
コード例 #6
0
 def test_one(self):
     """A single element requires no correction, should return 1.0."""
     ranks = np.array([1.0], dtype=np.float64)
     c = tiecorrect(ranks)
     assert_equal(c, 1.0)
コード例 #7
0
ファイル: test_rank.py プロジェクト: eelcovv/pywafo
 def test_empty(self):
     """An empty array requires no correction, should return 1.0."""
     ranks = np.array([], dtype=np.float64)
     c = tiecorrect(ranks)
     assert_equal(c, 1.0)
コード例 #8
0
ファイル: test_rank.py プロジェクト: eelcovv/pywafo
 def test_one(self):
     """A single element requires no correction, should return 1.0."""
     ranks = np.array([1.0], dtype=np.float64)
     c = tiecorrect(ranks)
     assert_equal(c, 1.0)