當前位置: 首頁>>代碼示例>>Python>>正文


Python statistics.median_low方法代碼示例

本文整理匯總了Python中statistics.median_low方法的典型用法代碼示例。如果您正苦於以下問題:Python statistics.median_low方法的具體用法?Python statistics.median_low怎麽用?Python statistics.median_low使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在statistics的用法示例。


在下文中一共展示了statistics.median_low方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_avg

# 需要導入模塊: import statistics [as 別名]
# 或者: from statistics import median_low [as 別名]
def get_avg(metrics: List):
        return median_low(metrics) 
開發者ID:hyperledger,項目名稱:indy-plenum,代碼行數:4,代碼來源:average_strategies.py

示例2: on_peer_response_append

# 需要導入模塊: import statistics [as 別名]
# 或者: from statistics import median_low [as 別名]
def on_peer_response_append(self, peer, msg):
        """Handle peer response to append_entries.
        If successful RPC, try to commit new entries.
        If RPC unsuccessful, backtrack."""
        if msg['success']:
            self.matchIndex[peer] = msg['matchIndex']
            self.nextIndex[peer] = msg['matchIndex'] + 1

            self.matchIndex[self.volatile['address']] = self.log.index
            self.nextIndex[self.volatile['address']] = self.log.index + 1
            index = statistics.median_low(self.matchIndex.values())
            self.log.commit(index)
            self.send_client_append_response()
        else:
            self.nextIndex[peer] = max(0, self.nextIndex[peer] - 1) 
開發者ID:simonacca,項目名稱:zatt,代碼行數:17,代碼來源:states.py

示例3: test_even_ints

# 需要導入模塊: import statistics [as 別名]
# 或者: from statistics import median_low [as 別名]
def test_even_ints(self):
        # Test median_low with an even number of ints.
        data = [1, 2, 3, 4, 5, 6]
        assert len(data)%2 == 0
        self.assertEqual(self.func(data), 3) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:7,代碼來源:test_statistics.py

示例4: test_even_fractions

# 需要導入模塊: import statistics [as 別名]
# 或者: from statistics import median_low [as 別名]
def test_even_fractions(self):
        # Test median_low works with an even number of Fractions.
        F = Fraction
        data = [F(1, 7), F(2, 7), F(3, 7), F(4, 7), F(5, 7), F(6, 7)]
        assert len(data)%2 == 0
        random.shuffle(data)
        self.assertEqual(self.func(data), F(3, 7)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:9,代碼來源:test_statistics.py

示例5: test_even_decimals

# 需要導入模塊: import statistics [as 別名]
# 或者: from statistics import median_low [as 別名]
def test_even_decimals(self):
        # Test median_low works with an even number of Decimals.
        D = Decimal
        data = [D('1.1'), D('2.2'), D('3.3'), D('4.4'), D('5.5'), D('6.6')]
        assert len(data)%2 == 0
        random.shuffle(data)
        self.assertEqual(self.func(data), D('3.3')) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:9,代碼來源:test_statistics.py

示例6: sortSubListsAndMedian

# 需要導入模塊: import statistics [as 別名]
# 或者: from statistics import median_low [as 別名]
def sortSubListsAndMedian(A):
    sortedList = []
    medianList = []
    for smallList in A:
        sortedList.append(sorted(smallList))
        medianList.append(statistics.median_low(smallList))
    return sortedList, medianList 
開發者ID:MauriceGit,項目名稱:Advanced_Algorithms,代碼行數:9,代碼來源:selection_det.py

示例7: MEDIAN_LOW

# 需要導入模塊: import statistics [as 別名]
# 或者: from statistics import median_low [as 別名]
def MEDIAN_LOW(df, n, price='Close'):
    """
    Low median of data
    Returns: list of floats = jhta.MEDIAN_LOW(df, n, price='Close')
    """
    median_low_list = []
    if n == len(df[price]):
        start = None
        for i in range(len(df[price])):
            if df[price][i] != df[price][i]:
                median_low = float('NaN')
            else:
                if start is None:
                    start = i
                end = i + 1
                median_low = statistics.median_low(df[price][start:end])
            median_low_list.append(median_low)
    else:
        for i in range(len(df[price])):
            if i + 1 < n:
                median_low = float('NaN')
            else:
                start = i + 1 - n
                end = i + 1
                median_low = statistics.median_low(df[price][start:end])
            median_low_list.append(median_low)
    return median_low_list 
開發者ID:joosthoeks,項目名稱:jhTAlib,代碼行數:29,代碼來源:statistic_functions.py

示例8: test_secint

# 需要導入模塊: import statistics [as 別名]
# 或者: from statistics import median_low [as 別名]
def test_secint(self):
        secint = mpc.SecInt()
        y = [1, 3, -2, 3, 1, -2, -2, 4] * 5
        random.shuffle(y)
        x = list(map(secint, y))
        self.assertEqual(mpc.run(mpc.output(mean(x))), round(statistics.mean(y)))
        self.assertEqual(mpc.run(mpc.output(variance(x))), round(statistics.variance(y)))
        self.assertEqual(mpc.run(mpc.output(variance(x, mean(x)))), round(statistics.variance(y)))
        self.assertEqual(mpc.run(mpc.output(stdev(x))), round(statistics.stdev(y)))
        self.assertEqual(mpc.run(mpc.output(pvariance(x))), round(statistics.pvariance(y)))
        self.assertEqual(mpc.run(mpc.output(pstdev(x))), round(statistics.pstdev(y)))
        self.assertEqual(mpc.run(mpc.output(mode(x))), round(statistics.mode(y)))
        self.assertEqual(mpc.run(mpc.output(median(x))), round(statistics.median(y)))
        self.assertEqual(mpc.run(mpc.output(median_low(x))), round(statistics.median_low(y)))
        self.assertEqual(mpc.run(mpc.output(median_high(x))), round(statistics.median_high(y))) 
開發者ID:lschoe,項目名稱:mpyc,代碼行數:17,代碼來源:test_statistics.py


注:本文中的statistics.median_low方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。