Popular recipes by Teodor Kichatov http://code.activestate.com/recipes/users/4176095/2010-11-30T17:38:38-08:00ActiveState Code RecipesSelect some nth smallest elements, quickselect, inplace (Python)
2010-11-30T07:32:42-08:00Teodor Kichatovhttp://code.activestate.com/recipes/users/4176095/http://code.activestate.com/recipes/577477-select-some-nth-smallest-elements-quickselect-inpl/
<p style="color: grey">
Python
recipe 577477
by <a href="/recipes/users/4176095/">Teodor Kichatov</a>
(<a href="/recipes/tags/quickselect/">quickselect</a>, <a href="/recipes/tags/search/">search</a>, <a href="/recipes/tags/selection/">selection</a>).
</p>
<p>fork of <a href="http://code.activestate.com/recipes/269554-select-the-nth-smallest-element/" rel="nofollow">http://code.activestate.com/recipes/269554-select-the-nth-smallest-element/</a>
O(n) quicksort style algorithm for looking up data based on rank order. Useful for finding medians, percentiles, quartiles, and deciles. Equivalent to [data[n] for n in positions] when the data is already sorted.</p>
Search nth smallest element in really big file (Python)
2010-11-30T17:38:38-08:00Teodor Kichatovhttp://code.activestate.com/recipes/users/4176095/http://code.activestate.com/recipes/577478-search-nth-smallest-element-in-really-big-file/
<p style="color: grey">
Python
recipe 577478
by <a href="/recipes/users/4176095/">Teodor Kichatov</a>
(<a href="/recipes/tags/big/">big</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/kth/">kth</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/search/">search</a>, <a href="/recipes/tags/selection/">selection</a>, <a href="/recipes/tags/smallest/">smallest</a>).
</p>
<p>Search nth smallest float in really big file (more, more and more bigger than available RAM)
in a single pass through the file</p>
<p>if your file more than 150GB - you should use a more appropriate sampling params to the data
more - you can use tempfile to store data(interval) returned from func fill_interval
data:
file with only one float number per line, good shuffled</p>