History

use a copy for the median use a copy for the median

Paul Brossier committed 20 years ago

Commit 0484dc11 parent dcc8d901 file · +6 −3Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/aubio/median.py+6−3
@@ -27,11 +27,14 @@ inspired from http://www.ics.uci.edu/~eppstein/161/python/peters-selection.py · 26 unmodified lines
27"""27"""
28 28
29def short_find(a, rank):29def short_find(a, rank):
30 a.sort()30 """ find the rank-th value in sorted a """
31 return a[rank - 1]31 # copy to b before sorting
32 b = a[:]
33 b.sort()
34 return b[rank - 1]
32 35
33# Find the rank'th-smallest value in a, in worst-case linear time.
34def percental(a, rank):36def percental(a, rank):
37 """ Find the rank'th-smallest value in a, in worst-case linear time. """
35 n = len(a)38 n = len(a)
36 assert 1 <= rank <= n39 assert 1 <= rank <= n
37 if n <= 7:40 if n <= 7:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t