Python statistics.median_low() Examples
The following are 17
code examples of statistics.median_low().
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 also want to check out all available functions/classes of the module
statistics
, or try the search function
.
Example #1
Source File: test_statistics.py From ironpython3 with Apache License 2.0 | 5 votes |
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'))
Example #2
Source File: test_statistics.py From android_universal with MIT License | 5 votes |
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'))
Example #3
Source File: test_statistics.py From android_universal with MIT License | 5 votes |
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))
Example #4
Source File: test_statistics.py From android_universal with MIT License | 5 votes |
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)
Example #5
Source File: test_statistics.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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'))
Example #6
Source File: test_statistics.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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))
Example #7
Source File: test_statistics.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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)
Example #8
Source File: test_statistics.py From mpyc with MIT License | 5 votes |
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)))
Example #9
Source File: statistic_functions.py From jhTAlib with GNU General Public License v3.0 | 5 votes |
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
Example #10
Source File: average_strategies.py From indy-plenum with Apache License 2.0 | 5 votes |
def get_avg(metrics: List): return median_low(metrics)
Example #11
Source File: test_statistics.py From ironpython3 with Apache License 2.0 | 5 votes |
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))
Example #12
Source File: test_statistics.py From ironpython3 with Apache License 2.0 | 5 votes |
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)
Example #13
Source File: selection_det.py From Advanced_Algorithms with ISC License | 5 votes |
def sortSubListsAndMedian(A): sortedList = [] medianList = [] for smallList in A: sortedList.append(sorted(smallList)) medianList.append(statistics.median_low(smallList)) return sortedList, medianList
Example #14
Source File: test_statistics.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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'))
Example #15
Source File: test_statistics.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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))
Example #16
Source File: test_statistics.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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)
Example #17
Source File: states.py From zatt with GNU Affero General Public License v3.0 | 5 votes |
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)