reworking
[p2pool.git] / p2pool / util / math.py
1 from __future__ import division
2
3 def median(x, use_float=True):
4     # there exist better algorithms...
5     y = sorted(x)
6     left = (len(y) - 1)//2
7     right = len(y)//2
8     sum = y[left] + y[right]
9     if use_float:
10         return sum/2
11     else:
12         return sum//2
13
14 def shuffled(x):
15     x = list(x)
16     random.shuffle(x)
17     return x