Thisis a python implementation of this paper,which proposes a heuristic algorithm for dynamic calculation of the median and other percentiles.It has the advantage of running in O(1) at each iteration and is hence particularly useful whendealing with continuously (and fastly) incoming data.
In the following example, we will estimate the value of the 95th percentile of a N(0,1) distributionusing p square algorithm. We will compare our estimates as we continuously draw from the distribution,by comparing with the truth value given by the numpy.percentile function. At the end, we will plotthe residuals, and the execution time using psquare and numpy.percentile.
3a8082e126