Upload TMIDIX.py
Browse files
TMIDIX.py
CHANGED
|
@@ -51,7 +51,7 @@ r'''############################################################################
|
|
| 51 |
|
| 52 |
###################################################################################
|
| 53 |
|
| 54 |
-
__version__ = "26.4.
|
| 55 |
|
| 56 |
print('=' * 70)
|
| 57 |
print('TMIDIX Python module')
|
|
@@ -18584,6 +18584,30 @@ def decode_delta_chord_tok_raw(delta_chord_tok):
|
|
| 18584 |
|
| 18585 |
###################################################################################
|
| 18586 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18587 |
print('Module loaded!')
|
| 18588 |
print('=' * 70)
|
| 18589 |
print('Enjoy! :)')
|
|
|
|
| 51 |
|
| 52 |
###################################################################################
|
| 53 |
|
| 54 |
+
__version__ = "26.4.21"
|
| 55 |
|
| 56 |
print('=' * 70)
|
| 57 |
print('TMIDIX Python module')
|
|
|
|
| 18584 |
|
| 18585 |
###################################################################################
|
| 18586 |
|
| 18587 |
+
def values_percentile(data, p):
|
| 18588 |
+
"""
|
| 18589 |
+
Return the p-th percentile of a list of ints using pure Python.
|
| 18590 |
+
Uses linear interpolation (same definition as NumPy).
|
| 18591 |
+
"""
|
| 18592 |
+
if not data:
|
| 18593 |
+
raise ValueError("data must not be empty")
|
| 18594 |
+
if not (0 <= p <= 100):
|
| 18595 |
+
raise ValueError("p must be between 0 and 100")
|
| 18596 |
+
|
| 18597 |
+
xs = sorted(data)
|
| 18598 |
+
n = len(xs)
|
| 18599 |
+
|
| 18600 |
+
# fractional index
|
| 18601 |
+
k = (p / 100) * (n - 1)
|
| 18602 |
+
i = int(k)
|
| 18603 |
+
f = k - i
|
| 18604 |
+
|
| 18605 |
+
if f == 0:
|
| 18606 |
+
return xs[i]
|
| 18607 |
+
return xs[i] + f * (xs[i + 1] - xs[i])
|
| 18608 |
+
|
| 18609 |
+
###################################################################################
|
| 18610 |
+
|
| 18611 |
print('Module loaded!')
|
| 18612 |
print('=' * 70)
|
| 18613 |
print('Enjoy! :)')
|