Popular recipes tagged "median" but not "statistics"http://code.activestate.com/recipes/tags/median-statistics/2013-03-06T17:33:32-08:00ActiveState Code RecipesRunning median, mean and mode (Python) 2013-03-06T17:33:32-08:00Virgil Stokeshttp://code.activestate.com/recipes/users/4183795/http://code.activestate.com/recipes/578480-running-median-mean-and-mode/ <p style="color: grey"> Python recipe 578480 by <a href="/recipes/users/4183795/">Virgil Stokes</a> (<a href="/recipes/tags/mean/">mean</a>, <a href="/recipes/tags/median/">median</a>, <a href="/recipes/tags/mode/">mode</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/running/">running</a>). </p> <p>The following is a small contribution that I hope can be useful to Python programmers for the calculation of the running median, mean and mode. It is important to note that all the "running" calculations are done for full windows. Here is a simple example:</p> <p>y = [1, 2, 3, 3, 1, 4], with a sliding window of size = 3 for the running estimations, means = 2, 2.6667, 2.3333, 2.6667 medians = 2, 3, 3, 3 modes = 1, 3, 3, 1</p> Efficient Running Median using an Indexable Skiplist (Python) 2010-02-07T14:40:03-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/576930-efficient-running-median-using-an-indexable-skipli/ <p style="color: grey"> Python recipe 576930 by <a href="/recipes/users/178123/">Raymond Hettinger</a> (<a href="/recipes/tags/advanced_data_structure/">advanced_data_structure</a>, <a href="/recipes/tags/container/">container</a>, <a href="/recipes/tags/median/">median</a>, <a href="/recipes/tags/new_algorithm/">new_algorithm</a>, <a href="/recipes/tags/skiplist/">skiplist</a>, <a href="/recipes/tags/sliding_window/">sliding_window</a>). Revision 10. </p> <p>Maintains sorted data as new elements are added and old one removed as a sliding window advances over a stream of data. Also gives fast indexed access to value. Running time per median update is proportional to the log of the window size.</p> Retrieving the median of a set in constant time (Python) 2011-04-19T15:00:57-07:00jimmy2timeshttp://code.activestate.com/recipes/users/4177690/http://code.activestate.com/recipes/577661-retrieving-the-median-of-a-set-in-constant-time/ <p style="color: grey"> Python recipe 577661 by <a href="/recipes/users/4177690/">jimmy2times</a> (<a href="/recipes/tags/data/">data</a>, <a href="/recipes/tags/heap/">heap</a>, <a href="/recipes/tags/median/">median</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/retrieving/">retrieving</a>, <a href="/recipes/tags/structure/">structure</a>). Revision 2. </p> <p>Provides a data structure for a queue of integers whose get() method returns the median element. The interface is similar to the standard Queue module, with an added method top() to retrieve the median without removing it.</p> Running Median (Python) 2010-02-20T08:22:00-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577059-running-median/ <p style="color: grey"> Python recipe 577059 by <a href="/recipes/users/178123/">Raymond Hettinger</a> (<a href="/recipes/tags/median/">median</a>). </p> <p>Maintains sorted data as new elements are added and old one removed as a sliding window advances over a stream of data. Running time per median calculation is proportional to the square-root of the window size.</p>