Created
May 22, 2020 01:47
-
-
Save StuffbyYuki/6f25f9f2f302cb5c1e82e4481016ccde to your computer and use it in GitHub Desktop.
Python: Numpy - trim mean function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def trimmean(arr, percent): | |
n = len(arr) | |
k = int(round(n*(float(percent)/100)/2)) | |
return np.mean(arr[k+1:n-k]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is arr sorted?