commit 95d091a87c3ebff8a35a57967b4e144898e2e1a5 Author: Karsten Loesing <karsten.loes...@gmx.net> Date: Sat May 19 21:02:28 2018 +0200
Compute percentiles in clients module using linear interpolation. So far we computed percentiles in the censorship detector of the clients module using our own formula that picked existing values as median or quartiles. Now we're using numpy.percentile which, by default, uses linear interpolation when the desired quantile lies between two data points. We're also removing unused imports of pylab and matplotlib in this commit, which is not directly related. Implements part of #26035. --- src/main/python/clients/detector.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/python/clients/detector.py b/src/main/python/clients/detector.py index 9944710..b0a98af 100644 --- a/src/main/python/clients/detector.py +++ b/src/main/python/clients/detector.py @@ -37,13 +37,9 @@ ## This script reads a .csv file of the number of Tor users and finds ## anomalies that might be indicative of censorship. -# Dep: matplotlib -from pylab import * -import matplotlib - # Dep: numpy import numpy -from numpy import mean, std +from numpy import mean, std, percentile # Dep: scipy import scipy.stats @@ -190,9 +186,9 @@ def make_tendencies_minmax(l, INTERVAL = 1): maxx += [None] else: vals.sort() - median = vals[len(vals)/2] - q1 = vals[len(vals)/4] - q2 = vals[(3*len(vals))/4] + median = percentile(vals, 50) + q1 = percentile(vals, 25) + q2 = percentile(vals, 75) qd = q2 - q1 vals = [v for v in vals if median - qd*4 < v and v < median + qd*4] if len(vals) < 8: _______________________________________________ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits